Environment Common methods:
* Method: Getdatadirectory ()
Explanation: Return File to get the Android data directory.
* Method: Getdownloadcachedirectory ()
Explanation: Return File to get the Android download/cache content directory.
* Method: getExternalStorageDirectory ()
Explanation: Return File, Get External storage directory is SDcard
* Method: Getexternalstoragepublicdirectory (String type)
Explanation: Return file, take a high-end common external memory directory to place certain types of files
* Method: Getexternalstoragestate ()
Explanation: Returns File to get the current state of the external storage device
* Method: Getrootdirectory ()
Explanation: Return File, get the root directory of Android
public void Getsdpath () {
File sddir = null;
File sdDir1 = null;
File sdDir2 = null;
Boolean sdcardexist = Environment.getexternalstoragestate ()
. Equals (Android.os.Environment.MEDIA_MOUNTED); Determine if the SD card exists
if (sdcardexist)
{
Sddir = Environment.getexternalstoragedirectory ();//Get with Directory
SdDir1 = Environment.getdatadirectory ();
SdDir2 =environment.getrootdirectory ();
}
System.out.println ("getExternalStorageDirectory ():" +sddir.tostring ());
System.out.println ("Getdatadirectory ():" +sddir1.tostring ());
System.out.println ("Getrootdirectory ():" +sddir2.tostring ());
}
Determine if a file (folder) exists under a path
public class Isexist {
public static void Main (string[] args) {
Isexist ("E://12");
}
/**
*
* Path @param path folder
*/
public static void Isexist (String path) {
File File = new file (path);
Determine if a folder exists and create a folder if it does not exist
if (!file.exists ()) {
File.mkdir ();
}
}
}
1. Create a folder on the SD card
public class make extends Activity {
/** called when the activity is first created. */
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
File sd=environment.getexternalstoragedirectory ();
String Path=sd.getpath () + "/notes";
File File=new file (path);
if (!file.exists ())
File.mkdir ();
}
Android Get Path directory method and determine if directory exists, create directory