Get file path from URI

前端 未结 8 1148
你的背包
你的背包 2020-12-03 01:54

I have Uri for Image file.

I use this code for gets file path from Uri:

public String getRealPathFromURI(Uri contentUri) {
    Cursor cursor = null;
         


        
8条回答
  •  长情又很酷
    2020-12-03 02:37

    I think this should work. A generalized code for getting URI from path :

    String path = yourAndroidURI.uri.getPath()
    File file = new File(new URI(path));
    

提交回复
热议问题