android文件读写
生活随笔
收集整理的這篇文章主要介紹了
android文件读写
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
public class service {
?private Context context;//引入上下文對象,要使用其中的方法openFileOutput
?
?
?public service(Context context) {
??super();
??this.context = context;
?}
?public void save(String filename,String content)throws Exception//拋出異常比較安全
?{
??FileOutputStream output=context.openFileOutput(filename, context.MODE_PRIVATE);//用文件輸出流,從應用中獲取數據存向手機
??//存儲卡,context為上下文對象,方法中第一個參數為文件名,的二個為傳數據的方式:私有
??output.write(content.getBytes());//寫入文件用二進制的方式
?}
}
轉載于:https://www.cnblogs.com/baiting/archive/2011/12/06/5346400.html
總結
以上是生活随笔為你收集整理的android文件读写的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【转】Mybatis/Ibatis,数据
- 下一篇: Tomcat免安装版的环境变量配置以及E