加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sqlite数据查询速度慢的可能原因

发布时间:2020-12-12 19:46:19 所属栏目:百科 来源:网络整理
导读:1.返回数据库字段信息与要查询数据库的数据字段不一致: 如下例:返回的字段少个 IMGURL String where = String::format("%s='%s'",AppBean::APPID().string(),appid.string()); DbResolver* p = DbResolver::getInstance(); if (p != NULL) { StringArray p

1.返回数据库字段信息与要查询数据库的数据字段不一致:

如下例:返回的字段少个IMGURL

String where = String::format("%s='%s'",AppBean::APPID().string(),appid.string());
DbResolver* p = DbResolver::getInstance();
if (p != NULL) {
StringArray pro(2);
pro.replaceAt(AppBean::PACKAGENAME(),0);
pro.replaceAt(AppBean::APPNAME(),1);
AutoCursor cursor = p->query(AppBean::DOWNLOAD_TABLE_NAME(),pro,where,StringArray(0),"");
if (cursor->moveToFirst()) {
String pkg = cursor->getString(cursor->getColumnIndex(AppBean::PACKAGENAME()));
String appname = cursor->getString(cursor->getColumnIndex(AppBean::APPNAME()));
String imageUrl = cursor->getString(cursor->getColumnIndex(AppBean::IMGURL()));
Demand d = NotificationDelegate::createDemand(appname,pkg,imageUrl,"",NotificationDelegate::STATUS_WAITDOWNLOAD,NotificationDelegate::PARAM_CANCEL);
mpContext->invokeDelegate(&d);
}

}


正确方式应为:
String where = String::format("%s='%s'",appid.string());
DbResolver* p = DbResolver::getInstance();
if (p != NULL) {
StringArray pro(3);
pro.replaceAt(AppBean::PACKAGENAME(),1);
pro.replaceAt(AppBean::IMGURL(),2);
AutoCursor cursor = p->query(AppBean::DOWNLOAD_TABLE_NAME(),"");
if (cursor->moveToFirst()) {
String pkg = cursor->getString(cursor->getColumnIndex(AppBean::PACKAGENAME()));
String appname = cursor->getString(cursor->getColumnIndex(AppBean::APPNAME()));
String imageUrl = cursor->getString(cursor->getColumnIndex(AppBean::IMGURL()));
Demand d = NotificationDelegate::createDemand(appname,NotificationDelegate::PARAM_CANCEL);
mpContext->invokeDelegate(&d);
}

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读