|
String |
Media_bad_removal |
The storage media has been removed before it is mounted. |
|
String |
Media_checking |
Checking storage media. |
|
String |
media_mounted |
The storage media is already mounted and the mount point is read/write. |
|
String |
Media_mounted_read_only |
The storage media has been mounted and the mount point is read-only. |
|
String |
Media_nofs |
The storage media is blank or unsupported file system. |
|
String |
Media_removed |
The storage media is removed. |
|
String |
Media_shared |
The storage media is being shared via USB. |
|
String |
Media_unmountable |
Storage media cannot be mounted. |
|
String |
media_unmounted |
Storage media is not mounted. |
|
Fields |
|||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
public static String |
Directory_alarms |
The standard directory where the system reminds the ringtone to be stored. |
|||||||||
|
public static String |
Directory_dcim |
A standard catalog of photos and videos taken by the camera. |
|||||||||
|
public static String |
Directory_downloads |
Download the standard Catalog. |
|||||||||
|
public static String |
Directory_movies |
Standard catalogue for film storage. |
|||||||||
|
public static String |
Directory_music |
Standard catalogue for music storage. |
|||||||||
|
public static String |
Directory_notifications |
The system notifies the standard directory where the ringtone is stored. |
|||||||||
|
public static String |
Directory_pictures |
A standard catalog of picture storage. |
|||||||||
|
public static String |
Directory_podcasts |
Standard directory for system broadcast storage. |
|||||||||
|
public static String |
Directory_ringtones |
Standard directory for system ringtone storage. |
|||||||||
|
Public Methods |
|||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
Static File |
Getdatadirectory () Get the directory for Android data. |
||||||||||
|
Static File |
Getdownloadcachedirectory () Get the download cache directory. |
||||||||||
|
Static File |
getExternalStorageDirectory () Or an external storage media directory. |
||||||||||
|
Static File |
Getexternalstoragepublicdirectory (String type) Get a top-level public external storage directory for placing files of a particular type. |
||||||||||
|
Static String |
Getexternalstoragestate () Gets the status of the current external storage media. |
||||||||||
|
Static File |
Getrootdirectory () Get a directory with Android. |
||||||||||
Get a top-level public external storage directory for placing files of a particular type. This is where the user would typically place and manage their own files, so you should being careful about what to put here T o ensure you don ' t erase their files or get in the the the their own organization.
Here's an example of typical code to manipulate a picture on the public external storage:
voidCreateexternalstoragepublicpicture() { Create a path where we'll place our picture in the user ' s Public Pictures directory. Note that you should is careful about What do you have here, since the user often manages these files. For Pictures and other media owned by the application, consider Context.getexternalmediadir (). FilePath= Environment.Getexternalstoragepublicdirectory( Environment.Directory_pictures); FileFile= New File(Path, "Demopicture.jpg"); Try { Make sure the Pictures directory exists.Path.Mkdirs(); Very simple code to copy a picture from the application ' s Resource into the external file. Note that this code does No error checking, and assumes the picture was small (does not Try to copy it in chunks). Note that if external storage is Not currently mounted this would silently fail. InputStream Is =Getresources().Openrawresource(R.Drawable.Balloons); OutputStreamOs= New FileOutputStream(File); Byte[]Data= New Byte[Is.Available()]; Is.Read(Data);Os.Write(Data); Is.Close();Os.Close(); Tell the media scanner on the new file so, it is//This step is very important!! Immediately available to the user. Mediascannerconnection.Scanfile(This, New String[] {File.Tostring() }, Null, New Mediascannerconnection.Onscancompletedlistener() { Public voidonscancompleted(StringPath, UriUri) { Log.I("Externalstorage", "Scanned" +Path+ ":"); Log.I("Externalstorage", "Uri=" +Uri); } }); } Catch (IOExceptionE) { Unable to create file, likely because external storage are Not currently mounted. Log.W("Externalstorage", "Error Writing" +File,E); }}voidDeleteexternalstoragepublicpicture()