I'm trying to set the image from a specific filepath ON THE PHONE. The filepath is to the photo on the phone. the filepath could look like this
/storage/emulated/0/Pictures/picture.jpg
Here is the code.
Bitmap image = null;
//trying to set the image from filepath
try {
image = BitmapFactory.decodeStream((InputStream) new URL(filepath).getContent());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (image == null) {
//This becomes true because the image is not set
Toast.makeText(getApplicationContext(),"image == null",Toast.LENGTH_LONG).show();
}
In the end the image is not set.