Today I have to deal with a difficult thing.
I start the camera and want so save the taken image directly to my internal storage, without moving it into it.
File targetDir = new File(getApplicationContext().getFilesDir()+File.separator+"PROJECTMAIN"+File.separator+"SUBFORDER");
targetDir.mkdirs(); //create the folder if they don't exist
File externalFile = new File(targetDir, "picturename.jpg");
Uri imageURI = Uri.fromFile(externalFile);
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageURI);
startActivityForResult(takePictureIntent, actionCode);
It seems that if I try to save them directly into the internal storage, the camera ignores my click on the "ok"-button after I take the picture. I think there is something wrong with the "internal" URI, because if I use Environment.getExternalStorageDirectory()
instead of getApplicationContext().getFilesDir()
for extra_output, everything works fine, but then I have to move the file afterwards into the internal storage (the movement process works fine to "getApplicationContext().getFilesDir()")
The camera just doesn't do anything when I take a picture and press the ok button to continue with the internal URI... I can't believe that is that difficult with storage in Android.
Any ideas? maybe the camera just allows to save pictures to the external storage?
Try following code
File dir= context.getDir("dirname", Context.MODE_PRIVATE); //Creates Dir inside internal memory
File file= new File(dir, "filename"); //It has directory details and file name
FileOutputStream fos = new FileOutputStream(file);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With