HY !!
我的应用程序中有一个登录表单,但我想保存/恢复应用程序内部的文本文件而不是内部手机内存。
是否有一些代码段?
我制作了一个内部文件保存/恢复,但它不起作用。
if (cb.isChecked())
{
File file = new File("/mmt/sdcard/login.skip");
Writer output = null;
try
{
output = new BufferedWriter(new FileWriter(file));
output.write(etuser.getText().toString()+ ";" + etpw.getText().toString());
output.close();
}
catch (Exception e) {
// TODO: handle exception
}
}
File file = new File("/mmt/sdcard/login.skip");
if(file.exists())
{ try
{
BufferedReader input = new BufferedReader(new FileReader(file));
while (( line = input.readLine()) != null){
line2 = line;
}
etuser.setText(line2.split(";")[0]);
etpw.setText(line2.split(";")[1]);
input.close();
}
catch (Exception e) {
// TODO: handle exception
}
}