How to show the captured image on the activity and simultaneously save it in the phone and inside the sqlite database?
<p>I have taken a reference of capturing the image and saving it into SD Card. That is working fine. Now i want the image will show onto the activity until i click the button.
        Can anybody suggest me that how to make it possible????</p>

<p>Here I am pasting the code. Kindly tell me where I am doing wrong here..</p>

<p>The DVCamera.class</p>

<pre><code>    public class DVCameraActivity extends Activity {  

        static Uri capturedImageUri=null;
        Button ButtonClick1,ButtonClick2;
        ImageView image1,image2;
        int CAMERA_PIC_REQUEST = 2; 
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            ButtonClick1 =(Button) findViewById(R.id.buttonClick1);
            ButtonClick2 = (Button) findViewById(R.id.buttonClick2);
            image2 =(ImageView) findViewById(R.id.PhotoCaptured2);
            image1 =(ImageView) findViewById(R.id.PhotoCaptured1);
            ButtonClick1.setOnClickListener(new OnClickListener (){
                @Override
                public void onClick(View view)
                {
                    Calendar cal = Calendar.getInstance();
                    File file = new File(Environment.getExternalStorageDirectory(),  (cal.getTimeInMillis()+".jpg"));
                    if(!file.exists()){
                        try {
                            file.createNewFile();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }else{
                        file.delete();
                        try {
                            file.createNewFile();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                    capturedImageUri = Uri.fromFile(file);
                    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                    // request code
                    //cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
                    startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

                }
            });

            ButtonClick2.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    Calendar cal = Calendar.getInstance();
                    File file = new File(Environment.getExternalStorageDirectory(),  (cal.getTimeInMillis()+".jpg"));
                    if(!file.exists()){
                        try {
                            file.createNewFile();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }else{
                        file.delete();
                        try {
                            file.createNewFile();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                    // TODO Auto-generated method stub
                    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                    // request code
                    //cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
                    capturedImageUri = Uri.fromFile(file);
                    startActivityForResult(cameraIntent, 1337);
                }
            });
        }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) 
        {
            if( requestCode == CAMERA_PIC_REQUEST)
            {
                //  data.getExtras()

                Bitmap bitmap = null;
                try {
                    bitmap = MediaStore.Images.Media.getBitmap( getApplicationContext().getContentResolver(),  capturedImageUri);
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                image1.setImageBitmap(bitmap);
            }
            else if(requestCode == 1337)
            {

                Bitmap bitmap = null;
                try {
                    bitmap = MediaStore.Images.Media.getBitmap( getApplicationContext().getContentResolver(),  capturedImageUri);
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                image2.setImageBitmap(bitmap);
            }
            else 
            {
                Toast.makeText(DVCameraActivity.this, "Picture NOt taken", Toast.LENGTH_LONG).show();
            }
            super.onActivityResult(requestCode, resultCode, data);
        }
    }
</code></pre>

<p>And hre is the layout file
    main.xml</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" &gt;

        &lt;LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" &gt;

            &lt;Button
                android:id="@+id/buttonClick1"
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:text="Click for Photo1" /&gt;

            &lt;Button
                android:id="@+id/buttonClick2"
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:text="Click for Photo2" /&gt;
        &lt;/LinearLayout&gt;

        &lt;LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" &gt;

            &lt;ImageView
                android:id="@+id/PhotoCaptured1"
                android:layout_width="150dp"
                android:layout_height="200dp" /&gt;
            &lt;ImageView
                android:id="@+id/PhotoCaptured2"
                android:layout_width="150dp"
                android:layout_height="200dp" /&gt;
        &lt;/LinearLayout&gt;
        &lt;!--
        &lt;FrameLayout
        android:id="@+id/camera_preview"
        android:layout_gravity="center"
        android:layout_width="200dp"
        android:layout_height="200dp"
        /&gt;
        --&gt;

    &lt;/LinearLayout&gt;
</code></pre>

<p>And if any1 can suggest me that what i have to do to save the captured image in the database,that will be another advantage for me.</p>

<p>Thanks in advance..</p>
