Android examples for android.os:Disk
get Application Storage Dir
import java.io.File; import android.content.ContextWrapper; import android.os.Environment; public class Main { public static File getApplicationStorageDir(ContextWrapper pContextWrapper) { File lApplicationDir = null;/* w ww.ja va2s . co m*/ if (isSdCardWritable()) { lApplicationDir = pContextWrapper.getExternalFilesDir(null); } else { lApplicationDir = pContextWrapper.getDir("data", ContextWrapper.MODE_WORLD_WRITEABLE); } return lApplicationDir; } public static boolean isSdCardWritable() { String lStorageState = Environment.getExternalStorageState(); boolean lIsSdcardWritable; boolean lIsSdCardAvailable; if (Environment.MEDIA_MOUNTED.equals(lStorageState)) { lIsSdCardAvailable = lIsSdcardWritable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(lStorageState)) { lIsSdCardAvailable = true; lIsSdcardWritable = false; } else { lIsSdCardAvailable = lIsSdcardWritable = false; } return lIsSdCardAvailable && lIsSdcardWritable; } }