1. 存储
try {
FileOutputStream outputStream = new FileOutputStream("data/data/com.example.ansel.qqlogin/loginInfo.txt");
Properties properties = new Properties();
properties.setProperty("account", accountEditText.getText().toString());
properties.setProperty("password", passwordEditTex.getText().toString());
properties.store(outputStream, "");
} catch (IOException e) {
e.printStackTrace();
}
2. 读取
try {
File file = new File("data/data/com.example.ansel.qqlogin/loginInfo.txt");
if (!file.exists() || file.length() <= 0) {
return;
}
FileInputStream inputStream = new FileInputStream(file);
Properties properties = new Properties();
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}