0

How can I create internal folder in my application to put the image captured in it after that get the image folder path ???

Salam
  • 11
  • 6

4 Answers4

0

inside Android you can create folder either on SD card (External Storage) or on internal memory.

the following command create a folder

file.mkdir()

so when you provide a file path like bellow

File file=new File(PATH/FOLDER_NAME);

it will create on specific location but if you do not provide path it will simply create folder on internal memory. which is basically

data/data/YOUR_APPLICATION_PACKAGE/
minhaz
  • 4,233
  • 3
  • 33
  • 49
0

path = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_MOVIES);

    File file = new File(path, "/" + fname);

You can add whatever folder name you want after "DIRECTORY_MOVIES" or "DIRECTORY_PICTURES" or whatever

Martin
  • 4,711
  • 4
  • 29
  • 37
0

Simply you can add this code on your camera capture button

File imagesFolder = new File(Environment.getExternalStorageDirectory(), "Your Folder Name");
                imagesFolder.mkdirs(); 
                Calendar cal = Calendar.getInstance();
                File photo = new File(Environment.getExternalStorageDirectory()
                        + "/Your Folder Name", (cal.getTimeInMillis() + ".jpg"));
                mCapturedImagePath = photo.getAbsolutePath();
                Uri uriSavedImage = Uri.fromFile(photo);
                Intent intent = new Intent(
                        android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
                startActivityForResult(intent, PICK_FROM_CAMERA);

The above code create a folder and save an Image into your SD card

Mukesh Y
  • 762
  • 6
  • 16
  • Thank you MR Mukesh but I want crate internal folder to save my image captured How Can I do it ? – Salam Apr 01 '13 at 14:13
  • You have to make this folder as private by "Context.MODE_PRIVATE", this helps you to make the folder private and not accessible by other application. Also when you remove the app from your device this private folder will also be removed.For more check the Internal storage on android developer site... http://developer.android.com/guide/topics/data/data-storage.html. – Mukesh Y Apr 02 '13 at 06:42
  • I tried to execute this code but i get the null values after that the app crashed :/ – Salam Apr 03 '13 at 21:45
0
path = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_MOVIES);

File file = new File(path, "/" + fname);

You can add whatever folder name you want after "DIRECTORY_MOVIES" or "DIRECTORY_PICTURES" or whatever - and it's internal to the device, and not external like on an SD card. It simply means that other apps can see this data and that it's not internal to the app and invisible to other apps or users

Martin
  • 4,711
  • 4
  • 29
  • 37