Android Question Match String on .txt file

German Buchmuller

Member
Licensed User
Longtime User
Hi, I want to know if the app can match a word (example: "germo") written on a txt file. How can I do that? Thanks!
 

mangojack

Expert
Licensed User
Longtime User
Try this .. Ensure to check StringUtils library.
B4X:
Sub GetUserName
  Dim TextReader1 As TextReader
  Dim User As String = "ABC"
  Dim Pword As String = "123"
 
  TextReader1.Initialize(File.OpenInput(File.DirRootExternal, "Text.txt"))
  Dim line As String
  line = TextReader1.ReadLine 
  Do While line <> Null
    If line = User Then  'if user is found then read next line to check password
       line = TextReader1.ReadLine
         If line = Pword Then
           Log ("User is OK")
         Else
           Log ("Incorrect password")
       End If   
     End If
  line = TextReader1.ReadLine
  Loop
  TextReader1.Close
End Sub

Following previous thread , I believe it would be best to store the Users name and password in a Database (for just this purpose it would be quite simple)
 
Upvote 0

Similar Threads

Top