Arun
Arun

Reputation: 1669

convert android.net.Uri to java.net.uri

i'm following along this answer: Android- how can I convert android.net.Uri object to java.net.URI object?

android.net.Uri INPUT_FILE;
java.net.URI juri = new java.net.URI(INPUT_FILE.toString());
File inputFile = new File(juri);

I get this error; java.lang.IllegalArgumentException: URI scheme is not "file"

The file is an mp4 inside the android Downloads directory. I'm currently using pixel 2 api 29. Any recommendations on how to fix the problem.

Upvotes: 0

Views: 214

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93542

The problem you have is that a File must be a file on disk. That means the URI must start with file:/// Your URI doesn't. Either your URI is malformed, or it isn't to a local file. Either of those would need to be fixed.

Upvotes: 1

Related Questions