Hi Friends, if you like my blog please give your valuable comments it will help to improve my blog content and enthusiasm to write a lot in android World.

Thursday, March 1, 2012

Android check SD card availability from code

Android check SD card availability from code

 
There is an easy way of finding the availability of SD in phone just by calling a method.
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