Convert Uri to String and String to Uri

前端 未结 5 1625
灰色年华
灰色年华 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:46

    You can use Drawable instead of Uri.

       ImageView iv=(ImageView)findViewById(R.id.imageView1);
       String pathName = "/external/images/media/470939"; 
       Drawable image = Drawable.createFromPath(pathName);
       iv.setImageDrawable(image);
    

    This would work.

提交回复
热议问题