List of utility methods to do SDCard Check
boolean | hasExternalStorage() has External Storage Boolean externalStorage = Environment.getExternalStorageState()
.equals(android.os.Environment.MEDIA_MOUNTED);
return externalStorage;
|
boolean | isExtStorageReadable() is Ext Storage Readable String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { return true; return false; |
boolean | isExtStorageWritable() is Ext Storage Writable String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { return true; return false; |
boolean | isExternalStorageWritable() is External Storage Writable String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { return true; return false; |
boolean | isExternalStoragePresent() private static boolean isExternalStoragePresent() this method can used to check that external storage(Sd card on device ) is available on device or not boolean mExternalStorageAvailable = false; boolean mExternalStorageWriteable = false; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { mExternalStorageAvailable = mExternalStorageWriteable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { mExternalStorageAvailable = true; mExternalStorageWriteable = false; ... |
File | getAlbumStorageDirectory(String albumName) get Album Storage Directory File file = new File( Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), albumName); if (!file.mkdirs()) { Log.e("", "Directory not created"); return file; ... |
File | getExtStoragePubDir(String dirName, String dirType) get Ext Storage Pub Dir File path = new File( Environment.getExternalStoragePublicDirectory(dirType), dirName); if (!path.mkdirs()) { Log.e("ExtStorageUtils", "Directory not created"); return path; |
long | getAvailableStorageSize(File dir) get Available Storage Size long size = -1; if (dir != null && dir.exists() && dir.isDirectory()) { try { StatFs stat = new StatFs(dir.getPath()); size = (long) stat.getBlockSize() * stat.getAvailableBlocks(); } catch (Exception e) { e.printStackTrace(); ... |
File | getDatafilesStorageDirectory(Context context) get Datafiles Storage Directory return context.getExternalFilesDir(null);
|