Reputation: 43
i dont understand why people say that is save in external storage because when i use this code and i check in my SD CARD is not have file
Code This one
OutputStream imageFileOS;
int imageNum = 0;
Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
File imagesFolder = new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES), "Punch");
if(!imagesFolder.exists()){
imagesFolder.mkdirs(); // <----
}
String fileName = "image_" + String.valueOf(imageNum) + ".jpg";
File output = new File(imagesFolder, fileName);
while (output.exists()){
imageNum++;
fileName = "image_" + String.valueOf(imageNum) + ".jpg";
output = new File(imagesFolder, fileName);
}
Uri uriSavedImage = Uri.fromFile(output);
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
when i run code and check ,It have file in "Internal Memory/Pictures/Punch/image_0.jpg" but not see in SD CARD (SD CARD = external memory card 16 GB) Please help me ..
Upvotes: 4
Views: 1854
Reputation: 13855
I think you are confused between what getExternalStorageDirectory
does.
It gets the primary storage directory, specified by the the device manufacturer. This is usually "sdcard". "External_sd" as specified in your comment is infact a secondary storage directory, which will not be returned in the given method.
This is still not the protected internal storage, and can be mounted and accessed by Pcs when connected.
From android docs:
Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.
Upvotes: 2