1. 程式人生 > >Android檔案儲存目錄

Android檔案儲存目錄

  • 儲存路徑包含包名的:使用context獲取;
  • 儲存路徑不包含包名的:使用Environment獲取;
/**
     * 顯示儲存空間路徑
     * <br/>
     */
    private static void showStorageUrl(Context mContext) {
        LogUtil.myW("getCacheDir():" + mContext.getCacheDir().getAbsolutePath());
        LogUtil.myW("getFilesDir:" + mContext.getFilesDir
().getAbsolutePath()); LogUtil.myW("getExternalCacheDir():" + mContext.getExternalCacheDir().getAbsolutePath()); LogUtil.myW("getExternalFilesDir(null):" + mContext.getExternalFilesDir(null).getAbsolutePath()); LogUtil.myW("getObbDir:" + mContext.getObbDir().getAbsolutePath());
LogUtil.myW("Environment.getDataDirectory():" + Environment.getDataDirectory()); LogUtil.myW("Environment.getDownloadCacheDirectory():" + Environment.getDownloadCacheDirectory()); LogUtil.myW("Environment.getRootDirectory():" + Environment.getRootDirectory()); LogUtil.myW
("Environment.getExternalStorageDirectory():" + Environment.getExternalStorageDirectory()); LogUtil.myW("Environment.getExternalStorageState():" + Environment.getExternalStorageState()); // 日誌顯示: // W/caowj: getCacheDir():/data/data/com.jsfengling.qipai/cache // W/caowj: getFilesDir:/data/data/com.jsfengling.qipai/files // W/caowj: getExternalCacheDir():/storage/emulated/0/Android/data/com.jsfengling.qipai/cache // W/caowj: getExternalFilesDir(null):/storage/emulated/0/Android/data/com.jsfengling.qipai/files // W/caowj: getObbDir:/storage/emulated/0/Android/obb/com.jsfengling.qipai // W/caowj: Environment.getDataDirectory():/data // W/caowj: Environment.getDownloadCacheDirectory():/cache // W/caowj: Environment.getRootDirectory():/system // W/caowj: Environment.getExternalStorageDirectory():/storage/emulated/0 // W/caowj: Environment.getExternalStorageState():mounted }