Skip to content

Instantly share code, notes, and snippets.

@beilly
Last active August 21, 2019 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beilly/40c664b273557293a2a906cb03759580 to your computer and use it in GitHub Desktop.
Save beilly/40c664b273557293a2a906cb03759580 to your computer and use it in GitHub Desktop.
记录Android系统文件访问权限
Log.i(TAG,context.getCacheDir().getPath());
///data/user/0/{packageName}/cache
Log.i(TAG,context.getFilesDir().getPath());
///data/user/0/{packageName}/files
Log.i(TAG,Environment.getExternalStorageDirectory().getPath());
///storage/emulated/0   需要权限
Log.i(TAG,context.getObbDir().getPath());
///storage/emulated/0/Android/obb/{packageName}  不需要权限,获取其他应用路径的需要权限
Log.i(TAG,context.getExternalCacheDir().getPath());
///storage/emulated/0/Android/data/{packageName}/cache   不需要权限,获取其他应用路径的需要权限
Log.i(TAG,context.getExternalFilesDir(null).getPath());
///storage/emulated/0/Android/data/{packageName}/files   不需要权限,获取其他应用路径的需要权限

总结:获取应用程序相关的缓存路径都不需要权限,获取其他路径需要授权。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment