title: Retrieving image (file path for image) from SQLite database and displaying it in ImageView
body: <p>I have asked this question earlier on today, but thought i would try and explain in more detail what my problem is.</p>
  
  <p>Okay I am going to try and give much information as I possibly can to explain my problem.</p>
  
  <p>So in my app the users can tap on any point on the map and add a custom marker, so when the user taps they can take a photo from the camera intent and return that image to the <code>customInfoWindow</code> I have.  So when the user then taps on the marker the image (thumbnail) is then displayed,  all of this works but once exiting the app and returning the markers are still displayed, but the images not.
  So this is what I do to get the image to that specific marker added:</p>
  
  <pre><code>private Map&lt;String, Bitmap&gt; myMarkersHash;
  private String markerId;
  .
  .
  .
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.fragment_googlemaps);
  
  myMarkersHash = new HashMap&lt;String, Bitmap&gt;();
  .
  .
  .
  @Override
  public void onMapLongClick(final LatLng point) {
  
  Marker marker = googleMap.addMarker(new MarkerOptions()
  .title(title.getText().toString())
  .snippet(snippet.getText().toString())
  .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE))
  .position(point));
  markerId = marker.getId();
  
  Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
  File imagesFolder = new File(Environment.getExternalStorageDirectory(), "Image");
  imagesFolder.mkdirs();
  image = new File(imagesFolder.getPath(), "MyImage_" + timeStamp + ".jpg");
  fileUri = Uri.fromFile(image);
    imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
  startActivityForResult(imageIntent, TAKE_PICTURE);
  
   public void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == TAKE_PICTURE &amp;&amp; resultCode == RESULT_OK) {
   try {
    GetImageThumbnail getImageThumbnail = new GetImageThumbnail();
    bitmap = getImageThumbnail.getThumbnail(fileUri, this);
     } catch (FileNotFoundException e1) {
            e1.printStackTrace();
    } catch (IOException e1) {
             e1.printStackTrace();
    }
  
  baos = new ByteArrayOutputStream();
    bitmap.compress(CompressFormat.PNG, 100, baos);
    imageData = baos.toByteArray();
  myMarkersHash.put(markerId, bitmap);
    .
    .
    .
   @Override
      public View getInfoContents(Marker marker)
      {
   View v  = getLayoutInflater().inflate(R.layout.infowindow_layout, null);
   ImageView markerIcon = (ImageView) v.findViewById(R.id.marker_icon);
   Bitmap bitmap = myMarkersHash.get(marker.getId());
   markerIcon.setImageBitmap(bitmap);
  </code></pre>
  
  <p>so the above code lets me add the marker and to display the correct image to that marker added.  Then I needed to save the marker info so when the user returns to the app the markers should then be displayed:</p>
  
  <pre><code> ContentValues contentValues = new ContentValues();
   contentValues.put(LocationsDB.FIELD_LAT, point.latitude);
   contentValues.put(LocationsDB.FIELD_LNG, point.longitude);
   contentValues.put(LocationsDB.FIELD_ZOOM, googleMap.getCameraPosition().zoom);
   contentValues.put(LocationsDB.FIELD_IMAGE, markerId);
   contentValues.put(LocationsDB.FIELD_FILEPATH, fileUri.toString());
   LocationInsertTask insertTask = new LocationInsertTask();
    insertTask.execute(contentValues)
   .
   .
   .
   private void drawMarker(LatLng point, byte[] id, byte[] filep) {
   Marker marker = googleMap.addMarker(new MarkerOptions()
   .title(title)
   .snippet(snippet)
   .position(thePoint));
   markerId = marker.getId();
  </code></pre>
  
  <p>Then when loading the data once the app starts:</p>
  
  <pre><code>@Override
  public void onLoadFinished(Loader&lt;Cursor&gt; arg0, Cursor arg1) {
  int locationCount = 0;
  double lat=0;
  double lng=0;
  float zoom=0;
  byte [] id = null;
  byte [] filep = null;
  locationCount = arg1.getCount();
  arg1.moveToFirst();
  
  for(int i=0;i&lt;locationCount;i++){
  
  lat = arg1.getDouble(arg1.getColumnIndex(LocationsDB.FIELD_LAT));
  lng = arg1.getDouble(arg1.getColumnIndex(LocationsDB.FIELD_LNG));
  zoom = arg1.getFloat(arg1.getColumnIndex(LocationsDB.FIELD_ZOOM));
  id = arg1.getBlob(arg1.getColumnIndex(LocationsDB.FIELD_IMAGE));
  filep = arg1.getBlob(arg1.getColumnIndex(LocationsDB.FIELD_FILEPATH));
  point = new LatLng(lat, lng);
  drawMarker(point, title, id, filep);
  arg1.moveToNext();
    }
  if(locationCount&gt;0){
   googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat,lng)));
   googleMap.animateCamera(CameraUpdateFactory.zoomTo(zoom));
   if(myMarkersHash.get(filep) != null &amp; id != null){
   bitmap = BitmapFactory.decodeFile(image.getAbsolutePath());
   final ImageView markerIcon = (ImageView) findViewById(R.id.marker_icon);
   markerIcon.setImageBitmap(bitmap);
      }
    }
  }
  </code></pre>
  
  <p>So as you can see it save the markers and all info* but does not load the image once the app restarts
  *the reason I know that it saves all the info is that when I access my database to view it I can then see the columns and the data:</p>
  
  <p><code>so for column 1  I have the ID  of “1” then Column 2 I have the lat point of “xx.xxxx” and Column 3 the lng point of “xx.xxxx” and then Column 4 the zoom of “9” and then Column 5 the markerId of “m01” and the Column 6 I have “file:///storage/emulated/0/Image/MyImage_yyyymmdd_HHmmss.jpg”</code></p>
  
  <p>So as you can see it definitely saves the information needed to load the markers with the images  but for some reason it doesn’t.  I also don’t get an error message or anything when the app starts again, all the markers are displayed but with no images.</p>
  
  <p>What can I do to resolve this problem?
  I really hope some one would be able to help me with this problem.
  Thanks in advance for your help.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>What i have tried now is:</p>
  
  <pre><code>File imgFile = new  File("fileUri");
   if(imgFile.exists())
     {
    ImageView myImage = (ImageView) findViewById(R.id.marker_icon);
    myImage.setImageURI(Uri.fromFile(imgFile));
  </code></pre>
  
  <p>But still the same thing.</p>