started learning java , app development. tried display single picture hard-coded path. got left error telling me, necessary permissions missing:
unable decode stream: java.io.filenotfoundexception: /storage/emulated/0/media/logo.jpg: open failed: eacces (permission denied)
androidmanifest.xml:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.snwflake22.helloworld" > <uses-permission android:name="android.permission.read_external_storage" /> <uses-permission android:name="android.permission.write_external_storage"/> <application (...) </application> </manifest> the function looks this:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); file image = new file(environment.getexternalstoragedirectory()+"/media/", "logo.jpg"); bitmapfactory.options bmoptions = new bitmapfactory.options(); bitmap bitmap = bitmapfactory.decodefile(image.getabsolutepath(), bmoptions); imageview imageview = (imageview) findviewbyid(r.id.imageview); imageview.setimagebitmap(bitmap); } are there other permissions need set access storage? or media folder?
use small caps on android.permission
<uses-permission android:name="android.permission.read_external_storage" /> <uses-permission android:name="android.permission.write_external_storage"/>
Comments
Post a Comment