public static java.lang.String | getStorageState(java.io.File path)Returns the current state of the storage device that provides the given
path.
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
return EnvironmentCompatKitKat.getStorageState(path);
}
try {
final String canonicalPath = path.getCanonicalPath();
final String canonicalExternal = Environment.getExternalStorageDirectory()
.getCanonicalPath();
if (canonicalPath.startsWith(canonicalExternal)) {
return Environment.getExternalStorageState();
}
} catch (IOException e) {
Log.w(TAG, "Failed to resolve canonical path: " + e);
}
return MEDIA_UNKNOWN;
|