I have an application with a built-in widget and I’m trying to read an image from my package folder (/data/data/com.package.name/pic.jpg) via my widget, but when I try to read it I get “Permission denied” in logcat. file.canRead() returns true so I’m not really sure what’s wrong here. Isn’t it allowed to read from the package folder via a widget?
Do I have to create the image on the sdcard to be able to read it or is there another way? I would prefer to read it from my package folder but it doesn’t seem to work.
Any ideas?
Thanks
I am going to assume that by “widget” you really mean “app widget”. If my assumption is incorrect, please ignore this answer. 🙂
The home screen needs to be able to read the image. The home screen runs in its own process and does not have rights to any of your files.
The home screen is not allowed to read from your app’s files. So, if you are using
setImageViewUri()with afile://Uri, that would be your problem.External storage would be one solution. Another would be to create the file using
openFileOutput()usingMODE_WORLD_READABLE. Yet another would be to create a tinyContentProviderand use acontent://Uri.