resolveUri失败的应用程序的私有数据文件 [英] resolveUri failing on app private data file

查看:195
本文介绍了resolveUri失败的应用程序的私有数据文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我产生了一堆的图像文件时,我的应用程序第一次运行,然后再尝试使用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(权限
  被拒绝)

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)

由于该文件是由这个应用程序创建的,我应该有权这个应用程序内访问它,对吗?这里的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失败的应用程序的私有数据文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆