urS*_*Sus 9 android join android-contentprovider android-cursorloader
我有两个1:1关系的表,我正在使用内容提供程序和cursorloader.
如何使用游标加载器进行连接查询?我可以用内容提供程序中的rawSql以某种方式破解它,但是如何在游标加载器构造函数中执行它是超出我的.
非常感谢 !
private static final String CREATE_TABLE_ARTICLES = "create table "
+ TABLE_ARTICLES + "("
+ COLUMN_ARTICLE_ID + " integer primary key autoincrement, "
+ COLUMN_URL + " text not null unique, "
+ COLUMN_TITLE + " text not null, "
+ COLUMN_PRICE + " text not null, "
+ COLUMN_ADDED + " text not null, "
+ COLUMN_IMG_URL + " text);";
private static final String CREATE_TABLE_ARTICLE_DETAIL = "create table "
+ TABLE_ARTICLE_DETAILS + "("
+ COLUMN_ARTICLE_DETAIL_ID + " integer primary key autoincrement, "
+ COLUMN_DESC + " text not null, "
+ COLUMN_LOCALITY + " text, "
+ COLUMN_TYPE + " text not null, "
+ COLUMN_SELLER + " text not null, "
+ COLUMN_SELLER_PHONE + " text, "
+ COLUMN_IMAGE_COUNT + " integer default 0, "
+ COLUMN_ARTICLE + " integer, foreign key (" + COLUMN_ARTICLE + ") references " + TABLE_ARTICLES + "(" + COLUMN_ARTICLE_ID + "));";
Run Code Online (Sandbox Code Playgroud)
实际上,您不必使用自定义任务加载器.简而言之,一种解决方案是创建一个Uri"content:// AUTHORITY/TableArticlesWithDetail".然后在内容提供程序中,检查该Uri并执行原始SQL以进行连接.
了解如何在CursorLoader中使用连接查询,当其构造函数不支持它以获取详细信息时.
| 归档时间: |
|
| 查看次数: |
5979 次 |
| 最近记录: |