参考:
demo
//====================================系统存储目录
String dataDirectory = Environment.getDataDirectory().getAbsolutePath();
System.out.println("dataDirectory ====== " + dataDirectory);
// /data
String downloadCacheDirectory = Environment.getDownloadCacheDirectory().getAbsolutePath();
System.out.println("downloadCacheDirectory ====== " + downloadCacheDirectory);
// /data/cache
String rootDirectory = Environment.getRootDirectory().getAbsolutePath();
System.out.println("rootDirectory ====== " + rootDirectory);
// /system
//===================================>应用内部存储 : 不root 无法查看
//adb push : Permission denied
String cacheDir = getCacheDir().getAbsolutePath();
System.out.println("cacheDir ====== " + cacheDir);
// 不同机型路径不同:
// /data/user/0/com.example.mylog/cache
// /data/data/com.example.mylog/cache
//adb push : Permission denied
String filesDir = getFilesDir().getAbsolutePath();
System.out.println("filesDir ====== " + filesDir);
// 不同机型路径不同:
// /data/user/0/com.example.mylog/files
// /data/data/com.example.mylog/files
//===================================>应用外部存储 - 公共目录(Environment):应用删除不会被删数据
//手机内置的外部存储可以用Environment的getExternalStorageDirectory等方法获取到。
String externalStorageDirectory = Environment.getExternalStorageDirectory().getAbsolutePath();
System.out.println("getExternalStorageDirectory ====== " + externalStorageDirectory);
// /storage/emulated/0
String externalStorageState = Environment.getExternalStorageState();
System.out.println("externalStorageState ======== "+externalStorageState);
//mounted
String externalStoragePublicDirectory_PICTURES = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
.getAbsolutePath();
System.out.println("externalStoragePublicDirectory_PICTURES === "+externalStoragePublicDirectory_PICTURES);
// /storage/emulated/0/Pictures
//===================================>应用外部存储 - 私有目录(context):应用删除会删数据
String externalCacheDir = getExternalCacheDir().getAbsolutePath();
System.out.println("getExternalCacheDir ====== " + externalCacheDir);
// /storage/emulated/0/Android/data/com.example.mylog/cache
String externalFilesDir_PICTURES = getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath();
System.out.println("externalFilesDir_PICTURES ====== " +externalFilesDir_PICTURES);
// /storage/emulated/0/Android/data/com.example.mylog/files/Pictures
String externalFilesDir_DOWNLOADS = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
System.out.println("externalFilesDir_DOWNLOADS ====== " +externalFilesDir_DOWNLOADS);
// /storage/emulated/0/Android/data/com.example.mylog/files/Download
adb pull/push 【from】 【to】
从手机向电脑传输文件:
adb pull 手机存储路径 电脑路径
adb pull /sdcard/xxx /Users/xxxx/xxx
从电脑向手机传输文件:
adb push 电脑路径 手机存储路径
adb push /Users/xxxx/xxx /sdcard/xxx