Да, вам нужно проверить наличие SD-карты, вам поможет следующая функция.
private boolean checkForDirectory()
{
boolean cardstate = true;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_BAD_REMOVAL.equals(state)) {
cardstate = false;
runDialog("Memory Card was removed before it was unmounted");
}
else if (Environment.MEDIA_CHECKING.equals(state)) {
runDialog("Memory Card is present and being disk-checked");
}
else if (Environment.MEDIA_MOUNTED.equals(state)) {
cardstate = true;
//runDialog("Memory Card is present and mounted with read/write access");
}
else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
runDialog("Memory Card is present and mounted with readonly access");
}
else if (Environment.MEDIA_NOFS.equals(state)) {
cardstate = false;
runDialog("Memory Card is present but is blank or using unsupported file system");
}
else if (Environment.MEDIA_REMOVED.equals(state)) {
cardstate = false;
runDialog("Memory Card is not present");
}
else if (Environment.MEDIA_SHARED.equals(state)) {
cardstate = false;
runDialog("Memory Card is present but shared via USB mass storage");
}
else if (Environment.MEDIA_UNMOUNTABLE.equals(state)) {
cardstate = false;
runDialog("Memory Card is present but cannot be mounted");
}
else if (Environment.MEDIA_UNMOUNTED.equals(state)) {
cardstate = false;
runDialog("Memory Card is present but not mounted");
}
File dir = new File(Environment.getExternalStorageDirectory() + "/gwc");
if(dir.exists() && dir.isDirectory())
{
System.out.println("Folder exists");
}
else
{
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
File myNewFolder = new File(extStorageDirectory + "/gwc");
myNewFolder.mkdir();
System.out.println("Folder gwc created ");
}
return cardstate;
}