![](/img/trans.png)
[英]Synchronization between Context.openFileInput and Context.openFileOutput
[英]Difference between Context.openFileInput() and using the Java.IO classes
上下文IO API(openFileInput和openFileOutput)與在Context.getFilesDir上使用Java的IO API有什么區別?
沒什么。 例如,這是ContextImpl
的openFileInput()
的實現( Context
的基本實現):
@Override
public FileInputStream openFileInput(String name)
throws FileNotFoundException {
File f = makeFilename(getFilesDir(), name);
return new FileInputStream(f);
}
如果文件名中包含目錄分隔符,則makeFilename()
會在這里大吼大叫。
我個人使用getFilesDir()
,因為它更靈活。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.