【发布时间】:2014-04-18 17:33:39
【问题描述】:
我有一个奇怪的问题。我正在从服务器获取数据并将其插入表中。插入后,我使用两个表之间的内连接查询该数据。 这是我的查询:
Select
F._id, F.id, F.logo, F.total_like, F.distance, F.store_name, F.mob_no_1,
F.mob_no_2, F.mob_no_3, F.tel_no_1, F.tel_no_2, F.tel_no_3, F.description,
R.total_record, R.total_page, R.current_page
from
FAVOURITE_STORES as F
INNER JOIN FAVOURITE_RECORDS as R on F.area_id = R.area_id
where
F.area_id = 2 and
R.area_id = 2
在某些设备上,光标计数为 1,而在某些设备上,光标计数为零。即使数据在表中。
这是我的选择查询函数
public Cursor rawQuery(String sQuery,String[] selectionArgs) {
if(mDatabase == null) {
mDatabase = getWritableDatabase();
}
debug("Query "+sQuery);
return mDatabase.rawQuery(sQuery,selectionArgs);
}
光标类
public class ExampleCursorLoader extends CursorLoader {
private Activity mActivity;
private String msQuery;
private DBUtil mDbUtil;
private String[] mSelectionArgs;
public ExampleCursorLoader(Activity context, String query,String[] selectionArgs) {
super(context);
this.mActivity = context;
this.msQuery = query;
this.mSelectionArgs = selectionArgs;
this.mDbUtil = DBUtil.getInstance(mActivity.getApplicationContext());
}
public ExampleCursorLoader(Activity context, String query) {
this(context,query,null);
debug(query);
}
public Cursor loadInBackground() {
debug("Loading in Background");
Cursor cursor=null;
cursor = mDbUtil.rawQuery(msQuery,mSelectionArgs);
return cursor;
}
private void debug(String s) {
Log.v("Adapter " , "Adapter " + s);
}
protected void onStartLoading() {
forceLoad();
debug("Started Loading");
}
protected void onStopLoading() {
super.onStopLoading();
}
}
我就是这样称呼它的。
return new ExampleCursorLoader(mActivity,sQuery);
计数为 1 的设备是三星 s3。零是三星大。 对此有什么想法或建议吗?
【问题讨论】:
-
尝试在没有加载程序的情况下执行您的查询,以表明这确实是 SQLite 问题,而不是您的加载程序的
-
@Drew 查询运行良好。我已经检查过了。
-
在两台设备上都运行良好,结果相同吗?如果是这样,问题出在你的加载器上
-
@Drew 你能告诉我可能出了什么问题吗?
-
如果你告诉我你是如何在你的活动/片段等中使用它的