title: Saving image file path to sqlite database
body: <p>I have have not found a practical example that specifically pertains to saving the file path of a image that you just took with the camera app to a SQLite database in your application.</p>
  
  <p>I have seen code to save an image from a HTML source... no good! My issue is that I have the URI but honestly, I can't figure out with the available data (dev guide, Stack Overflow questions) how to insert that file path to my database column.</p>
  
  <p>Here is my code where I try setting an edit text field so that the path is savable to the database. I tried this in the emulator:</p>
  
  <pre class="lang-java prettyprint-override"><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (requestCode == TAKE_PHOTO_CODE &amp;&amp; resultCode == RESULT_OK) {
          Bitmap x = (Bitmap) data.getExtras().get("data");
          File storagePath = new File(Environment.getExternalStorageDirectory() +
                                      "/DCIM/GPAA/"); 
          storagePath.mkdirs();
          File myImage = new File(storagePath,
                                  System.currentTimeMillis() + ".jpg");
          try { 
              FileOutputStream out = new FileOutputStream(myImage); 
              x.compress(Bitmap.CompressFormat.JPEG, 80, out); 
              Uri outputFileUri = Uri.fromFile(myImage);
              mnotesText = (EditText)findViewById(R.id.notes);
              mnotesText.setText (outputFileUri.toString());
              ((ImageView)findViewById(R.id.photoResultView)).setImageBitmap(x);
              out.close();
  
              Toast.makeText(Review.this, 
                             "Image saved: " + outputFileUri.toString(), 
                             Toast.LENGTH_LONG).show();
          } catch (FileNotFoundException e) {
          } catch (IOException e){
          }
      }
  }
  </code></pre>
  
  <p>With this code the toast verifies that the string is available and correct. However the entry to the <code>mnotesText.setText (outputFileUri.toString());</code> works in the emulator. But strangely enough will not work on the phone.</p>