public void save(String fileName,String fileContext) throws Exception{</span>
//创建输出流,并指定保存文件名fileName和保存模式
FileOutputStream outStream =context.openFileOutput(fileName, Context.MODE_PRIVATE);
outStream.write(fileContext.getBytes());
outStream.close();
}
保存后的文件位于sd卡中data-->data-->文件包名下
文件读取:<pre name="code" class="java">public String read(String filename) throws Exception{
FileInputStream inStream = context.openFileInput(filename);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
//从文件中读出来
while((len = inStream.read(buffer)) != -1){
//写入到内存中
outStream.write(buffer, 0, len);
}
//从内存中读出来
byte[] data = outStream.toByteArray();
return new String(data);
}