Skip to content Skip to sidebar Skip to footer

Android Get The Real Path And File Name From Uri

public void fileSearching(){ try{ // find1, find2 are buttons that open the file explorer find1.setOnClickListener(new View.OnClickListener(){ @Over

Solution 1:

Retrurns /external/file/59

That is because you did not look at the scheme of the Uri. getPath()only has meaning if the scheme is file. You will rarely get a Uri with a file scheme. Usually, it will have a content scheme, in which case the path is meaningless to you.

I need this because i want to get a sha-1,md5,... hash for any file.

Use ContentResolver and openInputStream() to get an InputStream on the content identified by the Uri. Pass that InputStream to your hashing algorithm.

Post a Comment for "Android Get The Real Path And File Name From Uri"