selected image path save last image path when image not take from camera
<p>i use camera for taking image from camera and use that image for showing it another activity..the camera open and it works and take  image but when i am not taking the image from camera means i just open the camera and click on back button means without taking image i go back then its onActivityforresult() called and showing last clicked image from camera so how to avoid it means if not take the image then it should go back to its previous activity without any nulll pointer exception and path of containing image should be null so for doing this we have to delete image from gallery or sdcard after doing it task or asign some null value to path of image ..pls help me...</p>

<p>my code for open camera and taking image and save it  external storage is below  ..</p>

<pre><code>          public void function(int id){

           selectedImagePath    =             Environment.getExternalStorageDirectory() + "/photo1.jpg";
                File file = new File(selectedImagePath);
                Uri outputFileUri = Uri.fromFile(file);
                Intent intent = new Intent(
                        android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);                
                startActivityForResult(intent, CAMERA_PIC_REQUEST);

        }

     public void onActivityResult(int requestCode, int resultCode, Intent data) {
            try{


            if (requestCode == CAMERA_PIC_REQUEST) {
                 if(selectedImagePath!=null){
                      Log.i("onActivityResult3","onActivityResult3");

                      Intent i=new Intent(getBaseContext(),Imageprview.class);
                      startActivity(i);
                      System.out.println(selectedImagePath);
                }

                 else
                        System.out.println("selectedImagePath is null");



                }}catch (NullPointerException e) {
                    // TODO: handle exception
                }   
</code></pre>

<p>so how to make selectedImagePath    =           null if i dont take any image from camera and back to my previous actity?</p>
