Android中各个路径的对应关系

注意

如果想通过以下语句Environment.getExternalStorageDirectory()访问genymotion的模拟器SDCard的根目录,需要写入文件或者是找文件到如下目录:/mnt/shell/emulate/0

Android中各个路径的对应关系_第1张图片
image.png

以下是Log代码:

            Log.d("路径1", "Environment.getDownloadCacheDirectory()--->" + Environment.getDownloadCacheDirectory().getAbsolutePath());
            Log.d("路径2", "Environment.getDataDirectory()--->" + Environment.getDataDirectory().getAbsolutePath());
            Log.d("路径3", "Environment.getExternalStoragePublicDirectory(\"test\")--->" + Environment.getExternalStoragePublicDirectory("test").getAbsolutePath());
            Log.d("路径4", "getExternalCacheDir()--->" + getExternalCacheDir().getAbsolutePath());
            Log.d("路径5", "getExternalFilesDir(\"test\")--->" + getExternalFilesDir("test").getAbsolutePath());
            Log.d("路径6", "getExternalFilesDir(null)--->" + getExternalFilesDir(null).getAbsolutePath());
            Log.d("路径7", "getFilesDir()--->" + getFilesDir().getAbsolutePath());

以下是对应的输出:

  • D/路径1: Environment.getDownloadCacheDirectory()--->/cache
  • D/路径2: Environment.getDataDirectory()--->/data
  • D/路径3: Environment.getExternalStoragePublicDirectory("test")--->/storage/emulated/0/test
  • D/路径4: getExternalCacheDir()--->/storage/emulated/0/Android/data/com.example.android.loadpic/cache
  • D/路径5: getExternalFilesDir("test")--->/storage/emulated/0/Android/data/com.example.android.loadpic/files/test
  • D/路径6: getExternalFilesDir(null)--->/storage/emulated/0/Android/data/com.example.android.loadpic/files
  • D/路径7: getFilesDir()--->/data/data/com.example.android.loadpic/files

你可能感兴趣的:(Android中各个路径的对应关系)