Convert Uri to String and String to Uri

前端 未结 5 1626
灰色年华
灰色年华 2020-12-08 18:37

I\'m developing some Application which allows select image from SD Card, save it into database and set this value for ImageView. I need to know way for converting uri to str

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 18:54

    I am not sure if you got this resolved. To follow up on "CommonsWare's" comment.

    That is not a valid string representation of a Uri. A Uri has a scheme, and "/external/images/media/470939" does not have a scheme.

    Change

    Uri uri=Uri.parse("/external/images/media/470939");
    

    to

    Uri uri=Uri.parse("content://external/images/media/470939");
    

    in my case

    Uri uri = Uri.parse("content://media/external/images/media/6562");
    

提交回复
热议问题