写私人文件的内部存储 [英] write private file to internal storage
问题描述
我试图写在内部存储一些文件。
我看到了的FileOutputStream FOS = openFileOutput(文件名,Context.MODE_PRIVATE);
上的数据存储,我明白,该文件将是私有的我的申请。
但问题是它只能打开一个文件没有路径,所以首先我打开了一个新的目录文件,file.mkdir(),但现在,我怎么写文件为私有?
我看到theFileOutputStream FOS = openFileOutput(文件名,Context.MODE_PRIVATE);在数据存储和我了解,该文件将是私有的我的申请。
块引用>正确的。他们将默认为私有的。
但问题是它只能打开一个文件没有路径,所以首先我打开了一个新的目录文件,file.mkdir(),但现在,我怎么写文件为私有?
块引用>您在子目录
创建了你的文件getFilesDir()
是私人默认情况下 - 你没有做什么特别的东西,使他们成为私有I trying to write some files on the internal storage.
I saw the
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
on Data Storage and I understood that the file will be private to my application.but the problem is it can only open a file without a path, so first I opened a new directory file with file.mkdir(), but now, how do I write the file as private ?
解决方案I saw theFileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); on Data Storage and I understood that the file will be private to my application.
Correct. They will be private by default.
but the problem is it can only open a file without a path, so first I opened a new directory file with file.mkdir(), but now, how do I write the file as private ?
Your files that you create in subdirectories off of in
getFilesDir()
are private by default -- you do not have to do anything special to make them be private.这篇关于写私人文件的内部存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!