开发者

Check SDCARD all possible state android

How can i check all possible state of SDCARD on android phone like ?

  1. SDCARD mounted via the USB cable
  2. SDCARD is installed
  3. SDCARD have authority to read and write. if card is not mounted through U开发者_StackOverflow社区SB cable.
  4. SDCARD have authority to read and write. if card is mounted through USB cable.
  5. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜