I use the following code to save password in a txt file:
String FILE_NAME="lol.txt";
public void writeData(String password){
FileOutputStream fOut = null;
OutputStreamWriter osw = null;
try{
fOut = openFileOutput(FILE_NAME, Context.MODE_PRIVATE);
osw = new OutputStreamWriter(fOut);
osw.write(password);
osw.close();
fOut.close();
}catch(Exception e){
e.printStackTrace(System.err);
}
}
but When I retrive the password that I just Saved using toast its appears OK, but when I Log it into my LogCat I got Something like the following:
gana???????????????????????????????????? .... and more four lines.
I save the word gana into my file using save method which work as OnClikc method that set value of EditText as password as below:
public void save(View v){
password= txt.getText().toString();
writeData(password);
}
any Way or clue how can I solve this problem?
regards
Use below code to reading file
only difference with your code is that i am using
new String(b).trim()to remove blank space.