// 读
public String get(String key) {
p = new Properties();
try {
InputStream in = new FileInputStream(Constants.PROP_PATH
+ "/login.properties");
p.load(in);
} catch (IOException e) {
e.printStackTrace();
}
return p.getProperty(key);
}
// 写
public void put(String key, String value) {
p = new Properties();
try {
InputStream in = new FileInputStream(Constants.PROP_PATH
+ "/login.properties");
p.load(in);
} catch (IOException e) {
e.printStackTrace();
}
p.setProperty(key, value);
OutputStream fos;
try {
fos = new FileOutputStream(Constants.PROP_PATH
+ "/login.properties");
p.store(fos, null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Constants.PROP_PATH = getApplicationContext().getFilesDir()
.getAbsolutePath();