private类型
- 只能本应用进行读写, 其他应用不可以访问
- 采用覆盖写的方法
- 举例
public void save(String filename,String content) throws IOException {
FileOutputStream outputStream = context.openFileOutput(filename, context.MODE_PRIVATE);
outputStream.write(content.getBytes());
outputStream.close();
}
append
- 只能本应用进行读写, 其他应用不可以访问
- 采用追加模式写
- 代码
public void saveAppend(String filename,String content) throws IOException {
FileOutputStream outputStream = context.openFileOutput(filename, context.MODE_APPEND);
outputStream.write(content.getBytes());
outputStream.close();
}
MODE_WORLD_WRITEABLE
- 创造的文件可以被其他应用写
allow all other applications to have write access to the created file.
MODE_WORLD_READABLE
- 创造的文件可以被其他应用读
allow all other applications to have read access to the created file.
参考链接
-API: http://www.android-doc.com/reference/android/content/Context.html