问题描述
我产生了一堆的图像文件时,我的应用程序第一次运行,然后再尝试使用remoteViews.setImageViewUri()后获得这些图像插入我的ImageViews。然而,当我跑我看到的应用
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
15 01-03:05:11.252:W / ImageView的(137):无法打开内容:
文件:///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(权限
被拒绝)
由于该文件是由这个应用程序创建的,我应该有权这个应用程序内访问它,对吗?这里的code我使用检索它:
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);
有什么想法?
推荐答案
Uri.parse
,使用 Uri.fromfile
。
Uri newUri = Uri.fromFile(file);
这篇关于resolveUri失败的应用程序的私有数据文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!