Android GetExternalFileDir()能否根据上下文返回不同的路径?

Android GetExternalFileDir()能否根据上下文返回不同的路径?,android,Android,例如,是否所有这些都保证为应用程序返回相同的结果 getApplicationContext().getExternalFilesDir() this.getExternalFilesDir()(this是SomeActivity) this.getExternalFilesDir()(this是SomeOtherActivity) this.getExternalFilesDir()(this是SomeService) 等等 类似的方法也是如此,例如,getExternalCacheDir

例如,是否所有这些都保证为应用程序返回相同的结果

  • getApplicationContext().getExternalFilesDir()
  • this.getExternalFilesDir()
    this
    SomeActivity
  • this.getExternalFilesDir()
    this
    SomeOtherActivity
  • this.getExternalFilesDir()
    this
    SomeService
  • 等等
类似的方法也是如此,例如,
getExternalCacheDir()
getFilesDir()
openFileOutput()
,等等

我想是的,它是基本的单例应用程序上下文,它定义了应用程序的媒体存储位置

是否所有这些都保证为应用程序返回相同的结果

嗯,后三个将无法编译。我假设您的意思是“该参数是我在这里提到的
活动
服务
的一个实例”


如果我的假设是正确的,那么您引用的
上下文
对象都不会改变结果。但是,请记住,对于设置了2+个帐户的设备,实际路径可能会有所不同,具体取决于运行应用程序的用户。

getExternalFilesDir()不将上下文对象作为参数。它们都需要一个字符串作为参数。好吧,这四个函数都无法编译,我匆忙地将上下文作为参数而不是调用者。:)我已经澄清了语法(但你的假设是正确的)。