Skip to content

Instantly share code, notes, and snippets.

@iAviatorJose
Created June 30, 2016 12:17
Show Gist options
  • Save iAviatorJose/1db9fcea577f35d0f9c2cc47be75b778 to your computer and use it in GitHub Desktop.
Save iAviatorJose/1db9fcea577f35d0f9c2cc47be75b778 to your computer and use it in GitHub Desktop.
Check Storage State
public static void checkState(File file){
String state = "";
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
state = Environment.getExternalStorageState(file);
} else if((Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)) {
Environment.getStorageState(file);
} else if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT){
state = Environment.getExternalStorageState();
}
Log.d(TAG,file.getAbsolutePath() + " STATE :" + state);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment