java - Android save camera picture to local storage -


today have deal difficult thing.

i start camera , want save taken image directly internal storage, without moving it.

    file targetdir = new file(getapplicationcontext().getfilesdir()+file.separator+"projectmain"+file.separator+"subforder");     targetdir.mkdirs(); //create folder if 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 if try save them directly internal storage, camera ignores click on "ok"-button after take picture. think there wrong "internal" uri, because if use environment.getexternalstoragedirectory() instead of getapplicationcontext().getfilesdir() extra_output, works fine, have move file afterwards internal storage (the movement process works fine "getapplicationcontext().getfilesdir()")

the camera doesn't when take picture , press ok button continue internal uri... can't believe difficult storage in android.

any ideas? maybe camera allows save pictures 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 , file name fileoutputstream fos = new fileoutputstream(file); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -