好吧……我难住了!我在 2013 年 2 月 13 日左右编写了以下代码,直到几天前它都运行良好:
/**
* 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”。查询的参数“Sector”和“Alliance”是有效的,并且存在于数据库的查询表中。
谢谢!