Androidstudio根据图片路径获取本地图片的方法

  1. String path="//sdcard//DCIM//a31.jpg";
    File file = new File(path);
    
    if(file.exists()){
        Bitmap bm = BitmapFactory.decodeFile(path);
        pruductImg.setImageBitmap(bm);
    }
    
  2. private ImageView pruductImg;
    pruductImg.setImageURI(
    Uri.fromFile(newFile(CommonParameter.getMyproduct().getmImg()))
    );