Android中Environment,context获取路径

 String tag = "testPath";
        //公有目录
        LogHelper.i(tag, "getDataDirectory=" + Environment.getDataDirectory().getPath());
        LogHelper.i(tag, "getDataDirectory().getParentFile=" + Environment.getDataDirectory().getParentFile().getPath());
        LogHelper.i(tag, "getDownloadCacheDirectory=" + Environment.getDownloadCacheDirectory().getPath());
        LogHelper.i(tag, "getRootDirectory=" + Environment.getRootDirectory().getPath());
        //私有目录
        LogHelper.i(tag, "getCodeCacheDir=" + ContextCompat.getCodeCacheDir(context).getPath());
        LogHelper.i(tag, "getDataDir=" + ContextCompat.getDataDir(context).getPath());
        LogHelper.i(tag, "getCacheDir=" + context.getCacheDir().getPath());
        LogHelper.i(tag, "getExternalCacheDir=" + context.getExternalCacheDir().getPath());
        LogHelper.i(tag, "getExternalFilesDir null=" + context.getExternalFilesDir(null).getPath());
        LogHelper.i(tag, "getExternalFilesDir(DIRECTORY_DCIM =" + context.getExternalFilesDir(Environment.DIRECTORY_DCIM).getPath());
        LogHelper.i(tag, "getExternalFilesDir=" + context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getPath());
        LogHelper.i(tag, "getExternalFilesDir=" + context.getExternalFilesDir(Environment.DIRECTORY_MOVIES).getPath());
        LogHelper.i(tag, "getExternalFilesDir=" + context.getExternalFilesDir(Environment.DIRECTORY_MUSIC).getPath());
2020-06-09 17:37:46.059 28628-28628/com.jzqf.smart I/testPath: getDataDirectory=/data
2020-06-09 17:37:46.059 28628-28628/com.jzqf.smart I/testPath: getDataDirectory().getParentFile=/
2020-06-09 17:37:46.059 28628-28628/com.jzqf.smart I/testPath: getDownloadCacheDirectory=/data/cache
2020-06-09 17:37:46.059 28628-28628/com.jzqf.smart I/testPath: getRootDirectory=/system
2020-06-09 17:37:46.059 28628-28628/com.jzqf.smart I/testPath: getCodeCacheDir=/data/user/0/com.jzqf.smart/code_cache
2020-06-09 17:37:46.059 28628-28628/com.jzqf.smart I/testPath: getDataDir=/data/user/0/com.jzqf.smart
2020-06-09 17:37:46.059 28628-28628/com.jzqf.smart I/testPath: getCacheDir=/data/user/0/com.jzqf.smart/cache
2020-06-09 17:37:46.060 28628-28628/com.jzqf.smart I/testPath: getExternalCacheDir=/storage/emulated/0/Android/data/com.jzqf.smart/cache
2020-06-09 17:37:46.061 28628-28628/com.jzqf.smart I/testPath: getExternalFilesDir null=/storage/emulated/0/Android/data/com.jzqf.smart/files
2020-06-09 17:37:46.061 28628-28628/com.jzqf.smart I/testPath: getExternalFilesDir=/storage/emulated/0/Android/data/com.jzqf.smart/files/DCIM
2020-06-09 17:37:46.061 28628-28628/com.jzqf.smart I/testPath: getExternalFilesDir=/storage/emulated/0/Android/data/com.jzqf.smart/files/Download
2020-06-09 17:37:46.062 28628-28628/com.jzqf.smart I/testPath: getExternalFilesDir=/storage/emulated/0/Android/data/com.jzqf.smart/files/Movies
2020-06-09 17:37:46.062 28628-28628/com.jzqf.smart I/testPath: getExternalFilesDir=/storage/emulated/0/Android/data/com.jzqf.smart/files/Music

 

你可能感兴趣的:(android)