【发布时间】:2012-12-28 22:24:06
【问题描述】:
我有两个具有 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 + "));";
【问题讨论】:
-
我很确定您将需要编写原始 SQL 来进行连接。
-
在创建 Cursor Loader 时如何编写原始 SQL 查询?它只接受这些字符串作为参数(投影、选择等)developer.android.com/reference/android/content/…
标签: android join android-contentprovider android-cursorloader