內部存儲文件即raw和assets項目文件夾下的文件,項目卸載時被刪除。
四種文件操作模式

文件存儲:
public void save(String filename, String filecontent) throws Exception {
//這里我們使用私有模式,創建出來的文件只能被本應用訪問,還會覆蓋原文件
FileOutputStream output = mContext.openFileOutput(filename, Context.MODE_PRIVATE);
output.write(filecontent.getBytes()); //將String字符串以字節流的形式寫入到輸出流中
output.close(); //關閉輸出流
}
文件讀取:
public String read(String filename) throws IOException {
//打開文件輸入流
FileInputStream input = mContext.openFileInput(filename);
byte[] temp = new byte[1024];
StringBuilder sb = new StringBuilder("");
int len = 0;
//讀取文件內容:
while ((len = input.read(temp)) > 0) {
sb.append(new String(temp, 0, len));
}
//關閉輸入流
input.close();
return sb.toString();
}
