title: Taking a picture and storing it to internal storage
body: <p>I'm trying to take a picture and when the user clicks the button, I want to save the picture to the internal storage. I will be testing on a tablet which does not have an sd card. I'm also new to taking pictures on android and the web has been no help with trying to find what specific code I need to write it to somewhere other than an sd card. Here is what my camera.java looks like.</p>
  
  <pre><code>package com.test;
  
  import com.test.R;
  
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  
  import android.app.Activity;
  
  import android.hardware.Camera;
  import android.hardware.Camera.PictureCallback;
  import android.hardware.Camera.ShutterCallback;
  
  import android.os.Bundle;
  
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.FrameLayout;
  
  public class camera extends Activity
  {
      private static final String TAG = "CameraDemo";
          Camera camera;
          Preview preview;
          Button buttonClick;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.camera);
  
          preview = new Preview(this);
          ((FrameLayout) findViewById(R.id.preview)).addView(preview);
  
          buttonClick = (Button) findViewById(R.id.buttonClick);
          buttonClick.setOnClickListener( new OnClickListener() {
              public void onClick(View v) {
                  preview.camera.takePicture(shutterCallback, rawCallback, jpegCallback);
              }
          });
  
          Log.d(TAG, "onCreate'd");
      }
  
  
      ShutterCallback shutterCallback = new ShutterCallback() {
          public void onShutter() {
              Log.d(TAG, "onShutter'd");
          }
      };
  
      /** Handles data for raw picture */
      PictureCallback rawCallback = new PictureCallback() {
          public void onPictureTaken(byte[] data, Camera camera) {
              Log.d(TAG, "onPictureTaken - raw");
          }
      };
  
      /** Handles data for jpeg picture */
      PictureCallback jpegCallback = new PictureCallback() {
          public void onPictureTaken(byte[] data, Camera camera) {
              FileOutputStream outStream = null;
              try {
                  // write to local sandbox file system
                  outStream = camera.this.openFileOutput(String.format("%d.jpg", System.currentTimeMillis()), 0); 
                  // Or write to sdcard
                  //outStream = new FileOutputStream(String.format("/sdcard/%d.jpg", System.currentTimeMillis()));    
                  outStream.write(data);
                  outStream.close();
                  Log.d(TAG, "onPictureTaken - wrote bytes: " + data.length);
              } catch (FileNotFoundException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              } finally {
              }
              Log.d(TAG, "onPictureTaken - jpeg");
          }
      };
  
  }
  </code></pre>