How can i check all possible state of SDCARD on android phone like ?
- SDCARD mounted via the USB cable
- SDCARD is installed
- SDCARD have authority to read and write. if card is not mounted through U开发者_StackOverflow社区SB cable.
- SDCARD have authority to read and write. if card is mounted through USB cable.
- SDCARD available size.
Thanks in advance.
To get the state, you can use this instruction:
String state = Environment.getExternalStorageState();
Then, for example, if you want to check if the SDCARD is mounted :
if (Environment.MEDIA_MOUNTED.equals(state))
You can find further information in the Android documentation.
There is a nice SO post here talking about detecting mounted sd card via USB.. Regards.
Please refer to http://developer.android.com/reference/android/os/Environment.html to get SDCARD state
And refer to http://developer.android.com/reference/android/os/StatFs.html to get SDCARD available size.
精彩评论