title: Save image view as a jpeg image in sdcard
body: <pre><code>public class MapDemoActivity extends Activity {
  
  Button capture;
  
      ImageView image;
      int cameracode=100;
      Bitmap bm;
      Boolean result;
      FileOutputStream fos;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          capture=(Button)findViewById(R.id.capture);
          capture.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                  image=(ImageView)findViewById(R.id.image);
                  Intent i=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                  startActivityForResult(i, cameracode);
                  image.setDrawingCacheEnabled(true);
                  bm = image.getDrawingCache();
  
                  try {
                      fos = new FileOutputStream("sdcard/image.jpg");
                      result=bm.compress(CompressFormat.JPEG, 75, fos);
  
                      fos.flush();
                      fos.close();
                  } catch (FileNotFoundException e) {
                      // TODO Auto-generated catch block
  
                      e.printStackTrace();
                  } catch (IOException e) {
                      // TODO Auto-generated catch block
  
                      e.printStackTrace();
                  }
  
  
              }
          });
  
      }
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          // TODO Auto-generated method stub
  
                      if(requestCode==100)
                      {
  
                          bm=(Bitmap) data.getExtras().get("data");
                          image.setImageBitmap(bm);
  
  
                      }
  
          super.onActivityResult(requestCode, resultCode, data);
      }
  }
  </code></pre>
  
  <p>In this prog i am capturing image from camera &amp; display to Image view then i am trying to 
  convert it to Jpeg to store in sdcard...
  But when i pressed <strong>capture image</strong> Button prog get force close..
  &amp; empty jpeg file created in sdcard... i want to store jpeg file to sdcard</p>