List of utility methods to do SDCard Check
boolean | hasMountSDCard() Detect whether SD card has mounted or not. return android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED);
|
long | getExternalStorageFreeSize() Obtain SD card free size. final StatFs statfs = new StatFs(Environment .getExternalStorageDirectory().getAbsolutePath()); final long availableBlocks = statfs.getAvailableBlocks(); final long blockSize = statfs.getBlockSize(); return availableBlocks * blockSize; |
long | getExternalStorageTotalSize() Obtain SD card total size. final StatFs statfs = new StatFs(Environment .getExternalStorageDirectory().getAbsolutePath()); final long blockCount = statfs.getBlockCount(); final long blockSize = statfs.getBlockSize(); return blockCount * blockSize; |
void | generateLogOnSD(String sBody, String fileName, String folderName) public static void generateLogOnSD(String sBody, String fileName, String folderName) this method can be used to write file on sd card. try { Log.d(TAG, "inside generateLogOnSD"); if (isExternalStoragePresent()) { File file = new File( Environment.getExternalStorageDirectory(), folderName); if (!file.exists()) { file.mkdirs(); ... |
String | getDataFilesDir(Context c) get Data Files Dir return c.getFilesDir().getAbsolutePath() + File.separator;
|
String | getSDPath() get SD Path String path = null; if (hasSdcard()) { File f = Environment.getExternalStorageDirectory(); path = f.toString(); return path; |
String | getSdCacheDir(Context context) get Sd Cache Dir if (Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED)) { java.io.File fExternalStorageDirectory = Environment .getExternalStorageDirectory(); java.io.File autonaviDir = new java.io.File( fExternalStorageDirectory, "amapsdk"); boolean result = false; if (!autonaviDir.exists()) { ... |
String | getSdcardFilesDir(Context c) get Sdcard Files Dir return c.getExternalFilesDir(null).getAbsolutePath()
+ File.separator;
|
boolean | hasSdcard() has Sdcard String status = Environment.getExternalStorageState(); if (status.equals(Environment.MEDIA_MOUNTED)) return true; else return false; |
boolean | isSDCardPresent() is SD Card Present return android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED);
|