title: How do I automatically upload the image I took to a cloud storage like Google Drive or Dropbox
body: <p>I'm a total newbie in Android programming and I was wondering if it's possible for me to automatically upload the image that I took using the camera app that i develop to a cloud storage like the Google Drive or Dropbox.  I am able to get the image saved to an internal SD Card currently.  Here's what I have so far:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.camera_main);
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  
      getWindow().setFormat(PixelFormat.UNKNOWN);
      surfaceView = (SurfaceView)findViewById(R.id.camerapreview);
      surfaceHolder = surfaceView.getHolder();
      surfaceHolder.addCallback(this);
      surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  
      controlInflater = LayoutInflater.from(getBaseContext());
      View viewControl = controlInflater.inflate(R.layout.camera_control, null);
      LayoutParams layoutParamsControl 
          = new LayoutParams(LayoutParams.FILL_PARENT, 
          LayoutParams.FILL_PARENT);
      this.addContentView(viewControl, layoutParamsControl);
  
      Button buttonTakePicture = (Button)findViewById(R.id.takepicture);
      buttonTakePicture.setOnClickListener(new Button.OnClickListener(){
  
  
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
              camera.takePicture(myShutterCallback, 
                      myPictureCallback_RAW, myPictureCallback_JPG);
          }});
  
  }
  
  ShutterCallback myShutterCallback = new ShutterCallback(){
  
      @Override
      public void onShutter() {
          // TODO Auto-generated method stub
  
      }};
  
  PictureCallback myPictureCallback_RAW = new PictureCallback(){
  
      @Override
      public void onPictureTaken(byte[] arg0, Camera arg1) {
          // TODO Auto-generated method stub
  
      }};
  
  PictureCallback myPictureCallback_JPG = new PictureCallback(){
  
      @Override
      public void onPictureTaken(byte[] arg0, Camera arg1) {
          // TODO Auto-generated method stub
          /*Bitmap bitmapPicture 
              = BitmapFactory.decodeByteArray(arg0, 0, arg0.length);  */
  
          /*Uri uriTarget = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues());
  
          /*OutputStream imageFileOS;*/
  
  
          FileOutputStream outStream = null;
  
          try 
          {
              /*imageFileOS = getContentResolver().openOutputStream(uriTarget);
              imageFileOS.write(arg0);
              imageFileOS.flush();
              imageFileOS.close();
  
              Toast.makeText(VuzixCamera.this, "Image saved: " + uriTarget.toString(), Toast.LENGTH_LONG).show();*/
  
              File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "nypdImages");
  
              if (!mediaStorageDir.exists()) 
              {
                  if (!mediaStorageDir.mkdirs()) 
                  {
                      Log.d("nypdImages", "Oops! Failed create " + "nypdImages" + " directory");
                  }
              }
  
              String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
              String path = mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg";
  
  
              outStream = new FileOutputStream(String.format(path, System.currentTimeMillis()));
              outStream.write(arg0);
              outStream.close();
  
              sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); 
  
          } 
          catch (FileNotFoundException e) 
          {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } 
          catch (IOException e) 
          {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          finally 
          {
              Toast.makeText(getApplicationContext(), "Image Saved", Toast.LENGTH_SHORT).show();
              //VuzixCamera.super.onBackPressed();
          }
  
          camera.startPreview();
      }};
  
  
  
  @Override
  public void surfaceChanged(SurfaceHolder holder, int format, int width,
          int height) {
      // TODO Auto-generated method stub
      if(previewing){
          camera.stopPreview();
          previewing = false;
      }
  
      if (camera != null){
          try {
              camera.setPreviewDisplay(surfaceHolder);
              camera.startPreview();
              previewing = true;
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  }
  
  @Override
  public void surfaceCreated(SurfaceHolder holder) {
      // TODO Auto-generated method stub
      camera = Camera.open();
  }
  
  @Override
  public void surfaceDestroyed(SurfaceHolder holder) {
      // TODO Auto-generated method stub
      camera.stopPreview();
      camera.release();
      camera = null;
      previewing = false;
  }
  </code></pre>