安卓 : How to write into internal memory

标签 android io

我把这段代码写到 sdcard 上,现在我怎样才能把它转换成写入内部存储器?

//private String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/liste.txt"; Path used to write on sdcard

try{
   File file = new File(path);

   BufferedWriter bw = new BufferedWriter(new FileWriter(file,true));
   bw.write("something");
    bw.flush();
    bw.close();
catch(Exception e) {...}

最佳答案

在android中,每个应用程序在/data/data/package/下都有自己的文件夹

此目录只能由您的应用程序和根目录访问如果设备已获得根目录

要访问此目录并对其进行读/写,您可以使用:

getApplicationContext().openFileOutput(name, mode);

getApplicationContext().openFileInput(name);

这里有更多相关信息:Docs

关于安卓 : How to write into internal memory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14660728/

相关文章:

android - ListView 项目中的动态 LinearLayout

java - Android 应用程序强制关闭(检索数据)

python - 如果我打开并读取周期写入的文件,会不会出现I/O死锁?

c++ - 在 C++ 中读取/写入设备

java - Android Studio - 从 Google Places Details API 电话号码解析 JSON,首次运行时给出 null

android - 应用安装未在 Google Play 控制台中列出

android - RecyclerView 面临的小问题

java - 是否有移动和覆盖文件的操作?

java - 如何将对象序列化到java中的非阻塞套接字

java - bufferedReader.readline 返回 null