Cannot access sdcard directory in Android -


i working on small app project calls camera.app, takes photo , returns photo on screen. can go through steps when photo local variable. however, when want save in specific path , read path, android warns

'e/bitmapfactory: unable decode stream: java.io.filenotfoundexception: /storage/emulated/0/camera_app/cam_image.jpg: open failed: enoent (no such file or directory)' 

there warnings don't understand, such as

 e/linker: readlink('/proc/self/fd/42') failed: permission denied [fd=42]   e/hiapp.serializedobject: thread-840{840} a.b(null:-1) <<< error >>> read file error/storage/emulated/0/android/data/com.huawei.appmarket/files/data/.appcheckinfo: open failed: enoent (no such file or directory) 

the computer can read sdcard. don't know how debug code

button button; imageview imageview; static final int cam_request = 1; string sdpath = environment.getexternalstoragedirectory().getabsolutepath();     textview sdcard; @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     button = (button) findviewbyid(r.id.bn);     imageview = (imageview) findviewbyid(r.id.img);     sdcard = (textview)findviewbyid(r.id.sdcard);     sdcard.settext(sdpath);     button.setonclicklistener(new view.onclicklistener(){         public void onclick(view v){             intent camera_intent = new intent(mediastore.action_image_capture);             file file = getfile();             uri contenturi = uri.fromfile(file);             camera_intent.putextra(mediastore.extra_output,contenturi);             startactivityforresult(camera_intent,cam_request);          }}); }  private file getfile(){     file folder = new file(sdpath+"/camera_app");//"eva-al10/sdcard/camera_app" "storage/1599-2841/camera_app"     if(!folder.exists()){         folder.mkdir();     }     file image_file = new file(folder,"cam_image.jpg");     return image_file; }  protected void onactivityresult(int requestcode, int resultcode, intent data){     string path = sdpath+"/camera_app/cam_image.jpg";//"eva-al10/sdcard/camera_app/cam_image.jpg"     imageview.setimagedrawable(drawable.createfrompath(path)); } 

updated xml:

<uses-feature android:name="android.hardware.camera2" android:required="true"></uses-feature> <uses-permission android:name="android.permission.write_external_storage"></uses-permission> <uses-permission android:name="android.permission.read_external_storage"></uses-permission> 

i think missing permission: read_external_storage


Comments