在网上搜索 3 天并尝试不同的东西后,我的知识已经结束。我正在尝试通过光标从 Android-SQLite 数据库中获取数据。使用此 SQLCode 创建数据库:
创建表 Passwort("ref text 主键,pw text)";
错误代码是这样的:
公共字符串suchen(字符串参考){
String antwort = "";
open();
try {
String rawQuery = "Select * FROM Passwort WHERE ref LIKE \"" + refe
+ "\"";
// Cursor c= db.query("Passwort", null, DBspalten[0]+"= '"+refe+"'",
// null, null, null, null);
Cursor c = db.rawQuery(rawQuery, null);
System.out.println(c.moveToFirst());
// normaly the "antwort" would be the second field of the Cursors first entry
// as told, the cursors is always empty
//antwort = "";
System.out.println("testausgabe:" + " " + c.getCount());
} catch (SQLException e) {
System.out.println("anderer Fehler");
}
return antwort;
}
我通过成功的插入语句插入了一个带有 ref="test" pw="QqjMs740Mg" 的条目。这个数据在数据库中是确定的,我通过数据库中的 Eclipse 插件找到了它。那么我的Cursor 的问题是什么,activ System.out.println-statment 总是提供false,这意味着Cursor 中没有数据。