簡體   English   中英

Context.openFileInput()與使用Java.IO類之間的區別

[英]Difference between Context.openFileInput() and using the Java.IO classes

上下文IO API(openFileInput和openFileOutput)與在Context.getFilesDir上使用Java的IO API有什么區別?

沒什么。 例如,這是ContextImplopenFileInput()的實現( 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM