directory - Android special directories -
I think that as API level 8, you handle special directories with Environment.getExternalStoragePublicDirectory () Can request for
. It takes a type like DIRECTORY_MUSIC
, DIRECTORY_PICTURES
, etc.
I have other media types such as documents (Word Docs, PDFs, etc.). My HTC Desire has a / sdcard / my document /
folder which is exactly what I want, but to use it with the above method DIRECTORY _
Specification Is not it a standard Android directory on which I can trust?
If I can not use getExternalStoragePublicDirectory ()
, then I get the getExternalStorageDirectory ()
instead of which only indicates the root of the SD card I can clearly check and use the presence of my document
below the root.
I have it:
// Save the default document location to the file's default SaveDir = Environment.getExternalStorageDirectory (); File myDocs = new file (default SaveDir, "My Documents"); If (myDocs.exists () & amp; amp; myDocs.is directory ()) defaultSaveDir = myDocs;
Is there a better way?
"My Documents" is not on my Nexus but instead I have a "document" directory. So it will not help in portable ways.
With SDK 8 you should use getExternalFilesDir - but be aware that there is a catch I had written a small article of my own
Finally I used:
final java.io.file storage = android.os.Environment.getExternalStorageDirectory (); Last java.io.file Dir = new java.io.file (Storage, "Android / Fx-603p"); Dir.mkdirs ();
I used the "Android" base directory because this is the new preferred method since SDK 8.
Comments
Post a Comment