How to change Uri to File on Android

Asked 1 years ago, Updated 1 years ago, 107 views

What is the easiest way to convert android.net.Uri to File?

final File file = new File(Environment.getExternalStorageDirectory(), "read.me");
 Uri uri = Uri.fromFile(file);
 File auxFile = new File(uri.toString());
 assertEquals(file.getAbsolutePath(), auxFile.getAbsolutePath());

I tried it like this, but it didn't work.

file android uri file-uri

2022-09-22 15:36

1 Answers

new File(uri.getPath()); This or new File(uri.toString()); You can do it in this way.


2022-09-22 15:36

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.