我用过很多次了openFileOutput.
例:
FileOutputStream fileOutputStream = openFileOutput(fileName, Context.MODE_PRIVATE);
Run Code Online (Sandbox Code Playgroud)
现在我注意到所有使用openFileOutput方法的文件都将放在私有app files目录中.
看起来像:
/data/data/com.my.app.app/files/example.txt
如何替换此方法以存储子目录上的Files?
例:
/data/data/com.my.app.app/files/subdirectory/example.txt
如何替换此方法以存储子目录上的Files?
更换:
FileOutputStream fileOutputStream = openFileOutput(fileName, Context.MODE_PRIVATE);
Run Code Online (Sandbox Code Playgroud)
有:
File dir=new File(getFilesDir(), dirName);
dir.mkdirs();
FileOutputStream fileOutputStream = new FileOutputStream(new File(dir, fileName));
Run Code Online (Sandbox Code Playgroud)
dirName您所需的子目录的名称在哪里.
| 归档时间: |
|
| 查看次数: |
2099 次 |
| 最近记录: |