for Android2.3 of systems,environment.getexternalstoragedirectory () Get the directory is built-in SD card or external SD card is not guaranteed, and the handset manufacturer's modification, Can only be judged by environment.isexternalstorageremovable ().,If True is external, because external can be uninstalled. (But I've only met Android at the moment. )The 4.4 system has a built-in SD card, soenvironment.getexternalstoragedirectory ()in the 2.3 system for external use, encountered special models and then consider other methods)
For Android 4.0 and above the system is good to do, you can use reflection to achieve the distinction between internal and external SD card, the code is as follows:
1StorageManager StorageManager =(StorageManager) Getsystemservice (context.storage_service);2 Try {3String [] strings = (string[]) Storagemanager.getclass (). GetMethod ("Getvolumepaths"). Invoke (StorageManager);4 for(inti = 0; i < strings.length; i++) {5 System.out.println (Strings[i]);6 }7}Catch(Exception e) {8 e.printstacktrace ();9}
And then call:
1 environment.getexternalstoragedirectory (); // get an SD card path 2 environment.isexternalstorageremovable (); // determine if the SD card is uninstalled
Next you will Environment.getexternalstoragedirectory (): ToString () Gets the string from the strings[i] inside the comparison, you can distinguish which is the built-in which is external.
&NBSP;
About the phone's built-in SD card and external SD card