title: Saving and recalling an image with a placeholder image as default in android
body: <p>I currently have a questionnaire, where each question is added dynamically in a db, which the app then receives for instructions. When it uses the camera, it sets the image just fine, using the code:</p>
  
  <pre><code>void setResponse(Bitmap image) {
      captureButton.setImageBitmap(image);
  }
  </code></pre>
  
  <p>Simple enough, right? When I click update, to save it to the sqlite db, I save it as a base64 string using this:</p>
  
  <pre><code>String getResponse() {
      String response = "";
       try 
          {
             Bitmap bitmap = Bitmap.createBitmap(captureButton.getDrawingCache());
             ByteArrayOutputStream stream = new ByteArrayOutputStream();
             bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream);
             byte[] image = stream.toByteArray();
             response = Base64.encodeToString(image, 0);
          } 
          catch (Exception e) 
          {   
             Log.e("Capture image error", e.getMessage());
             e.printStackTrace();
          }
       return response;
  }
  </code></pre>
  
  <p>And then when I go back into the questionnaire, if it has data already, it just loads it up using this:</p>
  
  <pre><code>void setResponse(String response) {
      byte[] decodedString = Base64.decode(response, Base64.DEFAULT);
      Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
      captureButton.setImageBitmap(decodedByte);
  }
  </code></pre>
  
  <p>I currently have pretty much the same system for signatures using the gestureOverlayView. But for this, I have a placeholder image defined in the CameraQuestionView.xml file:</p>
  
  <pre><code>  &lt;ImageView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_margin="10dp"
     android:src="@drawable/placeholder"
     android:id="@+id/cameraQuestionCaptureButton"/&gt;
  </code></pre>
  
  <p>But for some reason, when loading back up, the placeholder image is displayed instead of the saved image in the db. I tried invalidating the view, but that didn't work either. </p>
  
  <p>Thanks! </p>