上下文IO API(openFileInput和openFileOutput)与在Context.getFilesDir上使用Java的IO API有什么区别?
Nothing much. For example, here is the implementation of openFileInput()
from ContextImpl
(the base implementation of Context
):
@Override
public FileInputStream openFileInput(String name)
throws FileNotFoundException {
File f = makeFilename(getFilesDir(), name);
return new FileInputStream(f);
}
where makeFilename()
is there to yell at you if you have a directory separator in the filename.
Personally, I use getFilesDir()
, as it is more flexible.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.