tags:

views:

45

answers:

1

Looking at the example code in the docs http://developer.android.com/reference/android/content/Context.html#getExternalFilesDir%28java.lang.String%29

File path = getExternalFilesDir(Environment.DIRECTORY_PICTURES);

It does not compile on 2.1 The static fields DIRECTORY_PICTURES, DIRECTORY_MUSIC etc. don't seem to be found.

Update: Using the filter api checkbox, I see that it was removed in Android 2.2 (or api version 8). So the manifest file needs to contain minSdk defined as 7.

A: 

That's because this was added in Android 2.2 (API Level 8). See "Filter by API Level" in top right corner.

krtek
Yes, that is what I also just found. thanks!
Anil
But I also see that getExternalFilesDir() is only from level 8. What should one use from level 3-7 (android 1.5 - 2.1) instead?
Anil
Try what returns these methods on 2.2 and hardcode it in your application.
krtek
will the directory name be constant? I am not so sure. see http://developer.android.com/reference/android/os/Environment.html#getDataDirectory%28%29" Applications should not directly use this top-level directory, in order to avoid polluting the user's root namespace. Any files that are private to the application should be placed in a directory returned by Context.getExternalFilesDir, which the system will take care of deleting if the application is uninstalled. "
Anil