Question: I want to use default camera and capture image. i want save image in sdcard/photofolder/ and save filename as curenttime format in sdcard/photofolder/ also display capture image in imageview page

```
Uri outputFileUri = Uri.fromFile("/sdcard/Photofolder/");    
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, CAMERA_REQUEST);

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
            if (requestCode == CAMERA_REQUEST) {  
                Bitmap photo = (Bitmap) data.getExtras().get("data"); 
               // imageView.setImageBitmap(photo);

                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inSampleSize = 4;
                Bitmap bitmap = BitmapFactory.decodeFile(picFileName, options);
                imageView.setImageBitmap(bitmap);
                imageView.setVisibility(View.VISIBLE);

            }  
        }

```

any idea about this ?? thanks in adavance

Answer: 
You can get SDCard path like..

```
String root = Environment.getExternalStorageDirectory().toString();

new File(root + "/photofolder").mkdirs();

```

Then you can save a file to `root + "/photofolder/20120830025700.jpg"`.

---

Have you requested permission to write onto SD card? Add the following string to you app manifest:

```
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

```
Use this code to save image into SDcard and also create directory to store the captured image

```
  File photo = new File(Environment.getExternalStorageDirectory()+"/photofolder"); 
  System.out.println(photo.toString());
  boolean success = false;
  if(!photo.exists())
  { 
    success = photo.mkdirs(); 
  } 
    if(!success)
      {   

       Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
       photo = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Android/data/"+getApplicationContext().getPackageName()+"/files/Receipt", imagename+".png");
       Toast.makeText(this, photo.toString(), Toast.LENGTH_LONG);
       intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photo));
       Uri imageurl = Uri.fromFile(photo);  
       startActivityForResult(intent, CAMERA_RECEIPTREQUEST);   
       }  

```

To display the captured image use the below code

```
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {   
     super.onActivityResult(requestCode, resultCode, data);  

     switch(requestCode)
     {
     case CAMERA_RECEIPTREQUEST:  
         if(resultCode== Activity.RESULT_OK)
         {
             if(data!=null)   
                 { 
                         BitmapFactory.Options options = new BitmapFactory.Options();
                 options.inSampleSize = 8;
                 ImageView jpgView = (ImageView)findViewById(R.id.imageView1);
                 Bitmap receipt = BitmapFactory.decodeFile(photo.toString(),options);  
                  jpgView.setImage(receipt);
 }
 }
 }

```