Demo1
package com.example.androiddirectory;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
public class DirectoryUtils {
private static final String LOG_TAG="my_elliot";
public static void getEnvironmentDirectories(){
Log.d(LOG_TAG,"getRootDirectory:"+Environment.getRootDirectory().toString());
Log.d(LOG_TAG,"getDataDirectory:"+Environment.getDataDirectory().toString());
Log.d(LOG_TAG,"getDownloadCacheDirectory"+Environment.getDownloadCacheDirectory().toString());
Log.d(LOG_TAG,"getExternalStorageDirectory"+Environment.getExternalStorageDirectory().toString());
Log.d(LOG_TAG,"getExternalStorageDirectory"+Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS).toString());
Log.d(LOG_TAG,"getExternalStorageDirectory"+Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES).toString());
Log.d(LOG_TAG,"getExternalStorageDirectory"+Environment.getExternalStoragePublicDirectory(Environment.MEDIA_MOUNTED).toString());
}
public static void getApplicationDirectories(Context context){
Log.d(LOG_TAG,"context.getFilesDir().toString():"+context.getFilesDir().toString());
Log.d(LOG_TAG,"context.getCacheDir().toString():"+context.getCacheDir().toString());
Log.d(LOG_TAG,"context.getExternalFilesDir().toString():"+context.getExternalFilesDir(Environment.DIRECTORY_MOVIES).toString());
Log.d(LOG_TAG,"context.getExternalCacheDir().toString():"+context.getExternalCacheDir().toString());
}
}
result
02-23 19:30:07.644 D/my_elliot(16535): getRootDirectory:/system android的根目录
02-23 19:30:07.644 D/my_elliot(16535): getDataDirectory:/data 用户数据目录
02-23 19:30:07.645 D/my_elliot(16535): getDownloadCacheDirectory/cache 下载缓存内容目录
02-23 19:30:07.650 D/my_elliot(16535): getExternalStorageDirectory/storage/emulated/0 外部存储目录
02-23 19:30:07.664 D/my_elliot(16535): getExternalStorageDirectory/storage/emulated/0/Alarms 外部存储目录的Alarms类型
02-23 19:30:07.666 D/my_elliot(16535): getExternalStorageDirectory/storage/emulated/0/Ringtones 外部存储目录的Ringtones 类型
02-23 19:30:07.669 D/my_elliot(16535): getExternalStorageDirectory/storage/emulated/0/mounted 外部存储目录的mounted 类型
02-23 19:30:07.669 D/my_elliot(16535): context.getFilesDir().toString():/data/user/0/com.example.androiddirectory/files这个apk的files文件
02-23 19:30:07.670 D/my_elliot(16535): context.getCacheDir().toString():/data/user/0/com.example.androiddirectory/cache这个apk的cache文件
02-23 19:30:07.673 D/my_elliot(16535): context.getExternalFilesDir().toString():/storage/emulated/0/Android/data/com.example.androiddirectory/files/Movies这个apk的files文件
02-23 19:30:07.675 D/my_elliot(16535): context.getExternalCacheDir().toString():/storage/emulated/0/Android/data/com.example.androiddirectory/cache这个apk的cache文件
记录这些文件相关的api,以后看到不至于不知道文件存储的地方