image - Android - Unable to save photo in specified location if the photo is under DCIM file -


i'm facing problem:

when trying save photo specified location under file of app, if choose photo under dcim file, mobile(htc d816h version 4.4.2, has sd card) stores photo in other wrong place. however, if photo under pictures file select, cropped photo saved in correct place.

on other hand, when app runs on mobile same version(htc d626ph version 4.4.2) mine, there's nothing wrong , goes fine.

problem

why can't store photos in specified place if comes photos dcim file? , why problem happens on mobile?

procedure

first, select photo gallery of mobile. second, crop photo whatever size want. third, save cropped photo specified location in file of app. last, display cropped photo imageview.

i've made lots of research still not find solution or reason it. hope here. in advance!

here's code:

private uri m_uricropphoto = null;  private void crop(uri uriorig) {     file photo = null;      try {         string strfilepath = getfilepath(getactivity(), "profile_crop");         photo = createfile(strfilepath);     } catch(exception e) {         log.i("tag","can't create file take picture!");     }      m_uricropphoto = uri.fromfile(photo);      intent intent = new intent("com.android.camera.action.crop");     intent.setdataandtype(uriorig, "image/*");      list<resolveinfo> list = getactivity().getpackagemanager().queryintentactivities(intent, 0);      if (list.size() == 0) {         log.i("tag","can't crop picture!");     } else {         intent.putextra("crop", "true");         intent.putextra("return-data", false);         intent.putextra(mediastore.extra_output, m_uricropphoto);         startactivityforresult(intent,smycardsfragment.request_code_crop_photo);     }  }  private string getfilepath(string filename) {     file file = getactivity().getexternalfilesdir(null);      if (file != null) {         return string.format(locale.getdefault(), "%s/%s%s", file.tostring(), filename, ".jpg");     }      return null; }  private file createfile(string filepath) throws exception {     if (textutils.isempty(filepath) == true) {         return null;     }      file file = new file(filepath);     boolean iscreated = true;      if (file.exists() == false) {         iscreated = file.createnewfile();     }      return file; } 


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -