0
好吧......我很难过!我写了下面的代码大约13 - 2月 - 2013年和它前几天的工作完美截至:Android:SQLite函数不返回有效数据
/**
* Get a count of all resources in the selected Alliance
*
* @param db The EWTraker db
* @param Sector the Sector to be accessed
* @param Alliance the Alliance to be accessed */
public long[] getCountAllc(SQLiteDatabase db, String Sector, String Alliance){
if (BuildConfig.DEBUG) {
Log.i(Constants.TAG_DBHELPER, "getCountAllc(): Sector: "+Sector);
Log.i(Constants.TAG_DBHELPER, "getCountAllc(): Alliance: "+Alliance);
}
long[] mTblCountArray = new long[6];
String[] s = new String[2];
s[0] = Sector;
s[1] = Alliance;
try{
mTblCountArray[0] = DatabaseUtils.queryNumEntries(db,"TPLYS","FSECTR=? AND FANAME=?",s);
mTblCountArray[1] = DatabaseUtils.queryNumEntries(db,"TBASE","FSECTR=? AND FANAME=?",s);
mTblCountArray[2] = DatabaseUtils.queryNumEntries(db,"TBLDG","FSECTR=? AND FANAME=?",s);
mTblCountArray[3] = DatabaseUtils.queryNumEntries(db,"TTRPS","FSECTR=? AND FANAME=?",s);
mTblCountArray[4] = DatabaseUtils.queryNumEntries(db,"TINVY","FSECTR=? AND FANAME=?",s);
mTblCountArray[5] = DatabaseUtils.queryNumEntries(db,"TMSNS","FSECTR=? AND FANAME=?",s);
if (BuildConfig.DEBUG) {
Log.i(Constants.TAG_DBHELPER, "getCountAllc(): Alliance No. of Players: "+mTblCountArray[0]);
Log.i(Constants.TAG_DBHELPER, "getCountAllc(): Alliance No. of Bases: "+mTblCountArray[1]);
Log.i(Constants.TAG_DBHELPER, "getCountAllc(): Alliance No. of Buildings: "+mTblCountArray[2]);
Log.i(Constants.TAG_DBHELPER, "getCountAllc(): Alliance No. of Troup Rows: "+mTblCountArray[3]);
Log.i(Constants.TAG_DBHELPER, "getCountAllc(): Alliance No. of Items: "+mTblCountArray[4]);
Log.i(Constants.TAG_DBHELPER, "getCountAllc(): Alliance No. of Missions: "+mTblCountArray[5]);
}
} catch (Exception e) {
Log.e(Constants.TAG_DBHELPER, "getCountAllc(): Exception while getting record count:");
Log.e(Constants.TAG_DBHELPER, "getCountAllc(): Cause: "+e.getCause());
Log.e(Constants.TAG_DBHELPER, "getCountAllc(): Message: "+e.getMessage());
e.printStackTrace();
}
return mTblCountArray;
}
我在一个总损失并欢迎该会指出我在正确的方向上没有任何提示。当我知道100%时,数组中的所有数字都是'0',它们应该大于'0'。查询的“扇区”和“联盟”参数是有效的,并存在于数据库的查询表中。
谢谢!
发布您的queryNumEntries方法 – 2013-05-14 02:00:50