【发布时间】:2012-10-11 08:58:12
【问题描述】:
在网上搜索 3 天并尝试不同的东西后,我的知识已经结束了。 我正在尝试通过光标从 Android-SQLite 数据库中获取数据。数据库是用这个 SQLCode 创建的:
create table Passwort("ref text primary key, pw text)";
Buggcode 是这样的:
public String suchen(String refe) {
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 中没有数据。
【问题讨论】:
-
我用于测试的版本是API-10,因为我自己的智能手机有点旧
标签: java android-sqlite android-cursor