在内部存储中写文件

来源:互联网 发布:埃摩森猎头公司知乎 编辑:程序博客网 时间:2024/06/05 18:40
//getFilesDir()路径为:data/data/com.example.test/files//清除数据会清理里面的内容
//getCacheDir()路径为:data/data/com.example.test/cache//缓存文件夹,当手机内部存储空间不足时,里面的东西会被删除//清除缓存是清除里面的内容
File file=new File(getFilesDir(),"info.txt");try {    FileOutputStream fos=new FileOutputStream(file);    fos.write("hello".getBytes());    fos.close();} catch (Exception e) {    e.printStackTrace();}
0 0
原创粉丝点击