Environment.getExternalStorageDirectory() is deprecated过时

换为 getExternalFilesDir(null);
得到的路径如下:
/storage/emulated/0/Android/data/yourPackageName/files

getExternalFilesDir的参数可以传以下几种:

String?: The type of files directory to return. May be null for the root of the files directory or one of the following constants for a subdirectory: android.os.Environment#DIRECTORY_MUSIC, android.os.Environment#DIRECTORY_PODCASTS, android.os.Environment#DIRECTORY_RINGTONES, android.os.Environment#DIRECTORY_ALARMS, android.os.Environment#DIRECTORY_NOTIFICATIONS, android.os.Environment#DIRECTORY_PICTURES, or android.os.Environment#DIRECTORY_MOVIES. This value may be null.

例如我们传一个

getExternalFilesDir(Environment.DIRECTORY_PICTURES);
得到的路径如下:

/storage/emulated/0/Android/data/yourPackageName/files/Pictures

CV过来记录的,原文链接:https://blog.csdn.net/shving/article/details/101057082

你可能感兴趣的:(Environment.getExternalStorageDirectory() is deprecated过时)