android 文檔路徑獲取
public static void getFile(Context context){
LogDcjet.e("hanlx", "Environment.getExternalStorageDirectory()" +
Environment.getExternalStorageDirectory().getAbsolutePath());
// /storage/sdcard1
LogDcjet.e("hanlx", "Environment.getDataDirectory()" +
Environment.getDataDirectory().getAbsolutePath());
// /data
LogDcjet.e("hanlx", context.getCacheDir().getAbsolutePath());
// /data/data/com.dcjet.oa/cache
LogDcjet.e("hanlx", context.getExternalCacheDir().getAbsolutePath());
// /storage/sdcard1/Android/data/com.dcjet.oa/cache
LogDcjet.e("hanlx", context.getExternalFilesDir(null).getAbsolutePath());
///storage/sdcard1/Android/data/com.dcjet.oa/files
LogDcjet.e("hanlx", context.getFilesDir().getAbsolutePath());
// /data/data/com.dcjet.oa/files
Log.d("hanlx", Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED) + "");
//true
//以上是默認存儲位置設爲SD卡,保存在外存的數據保存在SD卡上
//以下是默認存儲位置設爲內存設備,保存到外存的數據保存在手機上,不root用文件管理器可以看到,卸載了sd卡判斷外存是否存在,結果是true;
// /storage/emulated/0
// /data
// /data/data/com.dcjet.oa/cache
// /storage/emulated/0/Android/data/com.dcjet.oa/cache
// /storage/emulated/0/Android/data/com.dcjet.oa/files
// /data/data/com.dcjet.oa/files
// true
LogDcjet.e("hanlx", "Environment.getExternalStorageDirectory()" +
Environment.getExternalStorageDirectory().getAbsolutePath());
// /storage/sdcard1
LogDcjet.e("hanlx", "Environment.getDataDirectory()" +
Environment.getDataDirectory().getAbsolutePath());
// /data
LogDcjet.e("hanlx", context.getCacheDir().getAbsolutePath());
// /data/data/com.dcjet.oa/cache
LogDcjet.e("hanlx", context.getExternalCacheDir().getAbsolutePath());
// /storage/sdcard1/Android/data/com.dcjet.oa/cache
LogDcjet.e("hanlx", context.getExternalFilesDir(null).getAbsolutePath());
///storage/sdcard1/Android/data/com.dcjet.oa/files
LogDcjet.e("hanlx", context.getFilesDir().getAbsolutePath());
// /data/data/com.dcjet.oa/files
Log.d("hanlx", Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED) + "");
//true
//以上是默認存儲位置設爲SD卡,保存在外存的數據保存在SD卡上
//以下是默認存儲位置設爲內存設備,保存到外存的數據保存在手機上,不root用文件管理器可以看到,卸載了sd卡判斷外存是否存在,結果是true;
// /storage/emulated/0
// /data
// /data/data/com.dcjet.oa/cache
// /storage/emulated/0/Android/data/com.dcjet.oa/cache
// /storage/emulated/0/Android/data/com.dcjet.oa/files
// /data/data/com.dcjet.oa/files
// true
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.