这是插入代码
for(int i = 0 ;pseudo.size() <= i; i++){
ContentValues values = new ContentValues();
String contact = (String) pseudo.get(i);
values.put("pseudo", contact);
values.put("adresse", "test");
values.put("image", "test");
values.put("ID", "5");
dbwrite.insert("Contact", null, values);
}
这是读取代码
String[] retour = {
"pseudo",
"xmppadresse",
"image", "ID"
};
Cursor cursor = dbread.query("Contact", retour, null, null, null, null, "pseudo");
Log.d("debug", "populateWithInitialContacts: "+cursor.getCount());
while(cursor.moveToNext()) {
String pseudo = cursor.getString(cursor.getColumnIndexOrThrow("pseudo"));
Log.d("debug", "getcontact: "+pseudo);
listcontact.add(new Contact(pseudo));
}
cursor.close();
我的请求什么都没有返回(这是我第一次在Android中使用数据库SQLite)
答案 0 :(得分:0)
for(int i = 0 ;pseudo.size() <= i; i++)
这不是你如何迭代列表。你可能想要像
这样的东西for(int i = 0 ;i < pseudo.size(); i++)