在我的应用程序中,我必须从设置页面设置一个密码并将其写入文件,之后当我进入主页时,如果文件为空,我必须读取该文件,我必须进入设置页面,
用于它的代码是......
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) {
}
如果密码已经设置,那么代码工作正常..但如果它是空的,它没有进入设置类......