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