如何模仿 Android API Level 8 之前的 Context.getExternalFilesDir() 方法?

7
Android API级别8引入了Context.getExternalFilesDir()方法,提供了一个File对象引用,指向一个与您的应用程序特定的SD卡路径。我想知道如何在低于API级别5的情况下模拟这个方法。
我看到有一个Context.getDir()方法,但我无法从阅读中了解它的区别。
1个回答

9

我最终在这里找到了答案。以下是那个页面的摘录,回答了我的问题:

If you're using API Level 7 or lower, use getExternalStorageDirectory(), to open a File representing the root of the external storage. You should then write your data in the following directory:

/Android/data/<package_name>/files/

The <package_name> is your Java-style package name, such as "com.example.android.app". If the user's device is running API Level 8 or greater and they uninstall your application, this directory and all its contents will be deleted.


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接