Android各种路径对应的值(持续更新)
2021-10-19 本文已影响0人
背锅TV丶伴奏大师
1.根据context获取的有:
String p1=getApplicationContext().getCacheDir().getPath();//用于获取APP的cache目录: /data/user/0/com.cobe.app/cache
String p2=getApplicationContext().getExternalCacheDir().getPath();//用于获取APP的在SD卡中的cache目录:/storage/emulated/0/Android/data/com.cobe.app/cache
String p3=getApplicationContext().getFilesDir().getPath();//用于获取APP的files目录: /data/user/0/com.cobe.app/files
String p4=getApplicationContext().getObbDir().getPath();//用于获取APPSDK中的obb目录:/storage/emulated/0/Android/obb/com.cobe.app
String p5=getApplicationContext().getPackageCodePath();//来获得当前应用程序对应的 apk 文件的路径:/data/app/com.cobe.app-r-_9KBOX_ijc0T-rEBL7Ug==/base.apk
String p6=getApplicationContext().getPackageResourcePath();//获取该程序的安装包路径:/data/app/com.cobe.app-r-_9KBOX_ijc0T-rEBL7Ug==/base.apk
2.Environment获取的有:
String p7=Environment.getDownloadCacheDirectory().getPath();//获得缓存目录:/data/cache
String p8=Environment.getDataDirectory().getPath();//获得根目录/data内部存储路径:/data
String p9=Environment.getRootDirectory().getPath();//获得系统目录:/system
String p10=Environment.getExternalStorageDirectory().getPath();//获得SD卡目录/mnt/sdcard(获取的是手机外置sd卡的路径):/storage/emulated/0
String p11=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS).getPath();//:/storage/emulated/0/Alarms
String p12=Environment.getStorageDirectory().getPath();//:/storage
String p13=Environment.getExternalStorageState();//获取外部存储设备的当前状态:mounted