在我的應用程序中,我必須從設置頁面設置一個密碼並將其寫入文件,之後當我進入主頁時,如果文件爲空,我必須讀取該文件進入到settinngs頁面,閱讀文件時遇到問題
用於它的代碼.....
try {
System.out.println("Enter try block!!!");
FileInputStream fis = openFileInput(FILENAME1);
InputStreamReader in = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(in);
data = br.readLine();
System.out.println("data from settings file"+data);
System.out.println("-------1Data Read From File is:1" + data);
if(data.equals(null))
{
Toast.makeText(getApplicationContext(), "You have to set a password", Toast.LENGTH_SHORT).show();
Intent in1 = new Intent();
in1.setClass(getApplicationContext(), SetteingsPage.class);
startActivity(in1);
}
} catch (Exception e) {
}
如果密碼已經設置,然後將代碼工作properly..But如果它爲null,則不進入設置類...