resolveUri failing on app private data file

南楼画角 提交于 2019-12-10 11:09:47

问题


I'm generating a bunch of image files when my app first runs, and then trying to use remoteViews.setImageViewUri() later to get these images into my ImageViews. However, when I run the app I'm seeing

01-03 15:05:11.252: W/ImageView(137): Unable to open content: file:///data/data/com.nickavv.cleanwidgets/files/batt_s_19.png 01-03 15:05:11.252: W/ImageView(137): java.io.FileNotFoundException: /data/data/com.nickavv.cleanwidgets/files/batt_s_19.png (Permission denied)

Since the file was created by this app, I should have permission to access it from within this app, right? Here's the code I'm using to retrieve it:

   File file = new File(context.getFilesDir().getPath(), idName+".png");
   Uri newUri = Uri.fromFile(file);
   myViews.setImageViewUri(id, newUri);

Any thoughts?


回答1:


Instead of using Uri.parse, use Uri.fromfile.

Uri newUri = Uri.fromFile(file);


来源:https://stackoverflow.com/questions/14146291/resolveuri-failing-on-app-private-data-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!