Java tutorial
//package com.java2s; import java.io.File; import java.io.IOException; public class Main { private static String T_FLASH_PATH = "/storage/sdcard1"; public static double getTFlashCardFreeSpace() { File dir; if (isTFlashCardExists()) { dir = new File(T_FLASH_PATH); return dir.getFreeSpace(); } return 0; } public static boolean isTFlashCardExists() { boolean tfExistsFlag = false; tfExistsFlag = new File(T_FLASH_PATH, "Android").exists(); if (getStorageDirWhenInsertSdcard() != null && testNewTfFile() == true) { tfExistsFlag = true; } return tfExistsFlag; } public static File getStorageDirWhenInsertSdcard() { File dir; try { dir = new File(T_FLASH_PATH, getMainDirName()); } catch (Exception e) { return null; } if (!dir.exists()) { dir.mkdirs(); } return dir; } public static boolean testNewTfFile() { File testFile = new File(T_FLASH_PATH, "testNewFile"); boolean returnFlag = false; if (!testFile.exists()) { try { if (testFile.createNewFile()) { returnFlag = true; testFile.delete(); } } catch (IOException e) { returnFlag = false; } } else { testFile.delete(); returnFlag = true; } return returnFlag; } public static String getMainDirName() { return "/aiowner"; } }