so what I am trying to accomplish is check a file to see if a word in the file matches the customers input.
I am attaching the code from when the button is clicked and what its supposed to do. Where its failing, or basically not doing it right, is where its supposed to check to see if it is in the list.
*CODE*
btn1.setOnClickListener(new OnClickListener() { // listen for when i click
public void onClick(View v) {
btn1.setText("yeah");
theirpass = edt1.getText().toString().toLowerCase(); // set theirpass = to text boxs input
System.out.println("before i read file theirpass =s "+ theirpass);
System.out.println("before i read file checking =s "+ checking);
readFile(); // read the accouts dude
tv1.setText("i pressed the button");// test to make sure button pressing works
System.out.println("after reading. theirpass =s " + theirpass);
System.out.println("after i read file. checking =s "+ checking);
}// end on click
}); //end listener
}// end oncreate
public void readFile() {
BufferedReader reader = null;
try {
reader = new BufferedReader(
new. InputStreamReader(getAssets().open("account.txt")));
// do reading, usually loop until end of file reading
String mLine = reader.readLine();// reading each line.
while (mLine != null) {
//process line
mLine = reader.readLine();
if. (mLine.matches(theirpass)) { // when an. account is found stop reading
System.out.println("cheking mLine"+ mLine);
checking = theirpass; //trying to set vale of. checking to theirpass
Log.d("if statement in mline",checking);
mLine=null;// trying to stop the loop
}//end if
}// end loop
} catch (IOException e) {
//log the exception
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
//log the exception
Log.d("Catch buffer","i failed the catch in finally for reading lines");
}
}
}//end buffer reader
Toast.makeText(this,checking,Toast.LENGTH_LONG).show(); //test to get. value of cheking, keeps coming up blank- no text
if (checking == theirpass) {
btn1.setText("its there");//test to see if the if statment works
System.out.println("i just checked if its there");//another test
}
}
}
To help with code
![helping with code again][2]
new Code
if (mLine.equals(theirpass)) { // when an account is found stop reading
System.out.println("cheking mLine"+ mLine);
checking.equals(theirpass); //trying to set vale of checking to theirpass
Log.d("if statement in mline",checking);
mLine=null;// trying to stop the loop
}//end if
mLine = reader.readLine();
} //end buffer reader
value of theirpass
//the value if theirpass is shown below it's in the onClick method
theirpass = edt1.getText().toString().toLowerCase(); // set theirpass = to text boxs input