Android我可以在URI中附加一个特定的记录字段吗?

Android我可以在URI中附加一个特定的记录字段吗?,android,sqlite,uri,Android,Sqlite,Uri,我在做Android开发 我的问题是:我可以将db记录的特定字段附加到URI吗 示例:假设您在SQLite数据库中有一个表: _id INTEGER AUTO INCREMENT name TEXT location TEXT picture BLOB 现在我想检索ID为4的条目的BLOB图像并显示它;我可以查询数据库 Bitmap monumentImage = null; Uri uri = Uri.parse("content://com.my.example/monuments/

我在做Android开发

我的问题是:我可以将db记录的特定字段附加到URI吗

示例:假设您在SQLite数据库中有一个表:

_id INTEGER AUTO INCREMENT   
name TEXT
location TEXT
picture BLOB
现在我想检索ID为4的条目的BLOB图像并显示它;我可以查询数据库

Bitmap monumentImage = null;
Uri uri = Uri.parse("content://com.my.example/monuments/4");
Cursor c = myContentResolver.query(uri, new String[] {"picture"}, null, null, null);
if (c.moveToFirst()) {
    byte[] imageBytes = c.getBlob(0);
    if (imageBytes != null) {
    monumentImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
}
ImageView myImage = findViewById(R.id.whatever);
if (monumentImage != null) {
    myImage.setImageBitmap(monumentImage);
}
现在我的问题是:有没有一种方法可以直接将记录列附加到uri中? 比如说,有

Uri uri = Uri.parse("content://com.my.example/monuments/4/picture");
ImageView myImage = findViewById(R.id.whatever);
myImage.setImageURI(uri);
?


干杯

是的。只需使用自己的内容提供商。在那里,您将能够解析URI。读,这个

提出质询


部分。

谢谢您的帮助。但是我认为用本机setImageURI()真的不可能实现我想要的功能。grepcode中公开的android代码,特别是“resolveUri()”函数,表明db记录中的字段不是一个好的候选字段。。。iv_backgroundImage.setImageURI(contactPhotoUriFull);