Android check SD card availability from code
This method return true when there is a SD card (external storage) available to store data in it.
Where can we use this function?
1. We can check the availability before writing a file into storage.
2.If you want an alternative to cache or download directory we can check the availability of SD card and use them.
The function is
[sourcecode language="java"]
public static boolean isSdPresent() {
return android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED);
}
[/sourcecode]
return type boolean(true->available,false->NA).
No comments:
Post a Comment