7.0各文件路径

转载出处:android 7.0文件存储API 

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());

    }

}

结果:

 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文件


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值