我要访问
getFilesDir()这是一个上下文方法
有没有什么办法可以同样访问到我访问外部存储的方式是什么?
Is there any way to access it similarly to the way i access external-storage?
Environment.getExternalStorageDirectory();
意义的环境变量?
也许应用静态上下文?因为我想从非上下文类调用这个(相同的应用程序服务,而不是一个活动)
Maybe application static context? as i want to call this from a non-context class (same app service, but not an activity)
推荐答案这是不可能的。
上下文 getFilesDir()返回绑定到你的包和一个路径背景才能访问包名。
Context getFilesDir() returns a path that is bound to your package and the Context is required to access the package name.
环保是不同的,因为只有公用的在同一个运行时运行的所有应用程序的常量。
Environment is different as there's only constants that are common to all apps running on the same runtime.
然而,一个上下文可几乎无处不在的Android应用程序,这不应该是一个真正的问题。
However, a Context is available practically everywhere in an Android application so this shouldn't really be a problem.
跟帖:
怎么样 Environment.getDataDirectory()?我怎样才能数据\数据从数据\数据\ com.Myapp 使用EnvironmentVar?
how about Environment.getDataDirectory()? how can i get data\data as from data\data\com.Myapp using EnvironmentVar?
Environment.getDataDirectory()只是返回通用于所有的应用程序数据目录的一部分。例如, /数据/数据。
Environment.getDataDirectory() just returns the part of the data directory common to all apps. For example, the /data/data.
要得到您自己的文件目录( getFilesDir()),您的包名和/文件需要要追加到它。 上下文的实施做这个给你。
To get your own files dir (getFilesDir()), your package name and "/files" need to be appended to it. Context implementation does this for you.
更多推荐
如何访问getFilesDir()作为环境变量?
发布评论