My app use the sd card for a SQLite DB. The device and sd card must be encrypted because some of the data on it (for the app) is proprietary. The app will fail if it is lunched immediately after a device restart because the sd card cannot be read (the notification bar says it is preparing the sd card). After the notification bar reports that the sd card is ready every thing is fine.
I have tried to test this with:
Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
if(isSDPresent)
{
// yes SD-card is present
}
else
{
// Sorry
}
from this question:
Check whether the SD card is available or not programmatically
and I have tried this:
boolean sdCardOK = false;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
sdCardOK = true;
} else {
//warn the user and kill the app
}
}
based on:
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
I could maybe just put a test text file on the sd card and try to read that. If it fails then warn the user and kill the app. But I would like to do something a little better. It seams like I should be able to get this info from the android os...
The device used for development (and for deployment) is the Samsung Tab 4. The SD cards are PNY 32GB and Kingston 32GB.