我把这段代码写到 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/