How to get External Storage Directory path in Android 10+

Viewed 1763

I want to Read files from External Storage, I developing Android App for Android 10+

I use this code to targetpath in android lower 9 version, but while using this code in Android 10 it's not working

String targetPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera";
        System.out.println("FilePath1" + targetPath);


//---->Output Filepath1

I/System.out: FilePath1/storage/emulated/0/DCIM/Camera

I tried this code for Android 10 but I getting Output something different:

File fileff = new File(getContext().getExternalFilesDir(null).getAbsolutePath() + "/DCIM/Camera");
        System.out.println("FilePath2" + fileff);


//---->Output Filepath2

I/System.out: FilePath2/storage/emulated/0/Android/data/com.learning.mylearning/files/DCIM/Camera

please help me, how should I get Filepath1 in Android 10?

Thanks in Advance =)

0 Answers
Related