First:
This small demo is to determine whether the phone is inserted into the SD card (manually inserted into the case of the mobile card slot), if the SD card is unplugged, it will detect that there is no SD, will prompt to exit. You can modify the code to achieve your desired effect.
SD card loading status is obtained from the system files, "/system/etc/vold.fstab" and "/proc/mounts" (Detailed mount process can refer to this blog http://blog.csdn.net/yihongyuelan/ article/details/6963485).
However, there is a problem, 4.0 after the external SD read and write permissions into the system permissions, so if not the system application can not read and write external SD card. But when I get to the external SD card path, I find that I can read and write,
It is not known whether the setwritable (true) setting is the cause. What's wrong with everyone to communicate together.
What is an external SD card and a built-in SD card?
External: There is an extended SD card slot on the phone, the SD card inserted here is called an external SD card.
Built-in: is the phone's own SD, such as the current 16g, 32g mobile phones are built-in a 16g or 32g SD card.
Note: Some older mobile phones have a card slot but no built-in SD card, but the card slot is inserted as an internal SD card. (So I made a decision in the code: environment.isexternalstorageremovable () This method to determine whether the built-in SD card can be removed, can be removed to indicate that the phone has a card slot but no built-in SD card)
Demo Download: Http://files.cnblogs.com/wangyuehome/testAndroid.zip