title: Camera Intent picture file path
body: <p>I'm trying to get the path of the pictures that i take with the camera as a String. When i try to take the pictures with my code then the String is empty. When i close my app, open the camera app and take a picture there, then re-open my app and use my code then i get the String of the last photo that i took with the camera app. My question is why does my Camera Intent not work and why does it work when i use the camera app?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public void onClick(View arg0) {
      switch (arg0.getId()) {     
        case R.id.btnImageCapture:
          Intent openCamera = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(openCamera, OPEN_CAMERA); 
                      break;
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>private String getLastImagePath() {
              final String[] imageColumns = { MediaStore.Images.Media._ID,
                      MediaStore.Images.Media.DATA };
              final String imageOrderBy = MediaStore.Images.Media._ID + " DESC";
              Cursor imageCursor = managedQuery(
                      MediaStore.Images.Media.EXTERNAL_CONTENT_URI, imageColumns,
                      null, null, imageOrderBy);
              if (imageCursor.moveToFirst()) {
                  String fullPath = imageCursor.getString(imageCursor
                          .getColumnIndex(MediaStore.Images.Media.DATA));
                  imageCursor.close();
                  return fullPath;
              }
          }
  </code></pre>
  
  <hr>
  
  <pre><code>        @Override
          protected void onActivityResult(int requestCode, int resultCode, Intent data) {
           switch(requestCode){
           case OPEN_CAMERA:
               if (resultCode == RESULT_OK &amp;&amp; data != null) {
                   String picturePath = getLastImagePath(); 
                   break;
               } 
               }
          }
  </code></pre>