【发布时间】:2019-03-19 12:06:14
【问题描述】:
在我的 SQLite 中实际上有 375 个数据,但是当我尝试迭代该数据并分配给 hashmap 时,仅成功分配了 226 个数据,我下面的代码有什么问题?
public static HashMap<String, String> getLanguage() {
HashMap<String,String> hashMap = new HashMap<>();
Cursor cursor = database.query(DB_TABLE
, null
, null
, null
, null
, null, _ID + " ASC"
, null);
//cursor.moveToFirst();
System.out.println("Cursor count"+cursor.getCount());
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
hashMap.put(cursor.getString(cursor.getColumnIndex(KEY_LANG)), cursor.getString(cursor.getColumnIndex(STRING)));
}
return hashMap;
}
【问题讨论】: