Java 为什么我会得到android.database.sqlite.sqlitecursor@error
每当我试图显示nexpdate的值时,就会得到null值。我得到以下错误:android.database.sqlite.sqlitecursor@Java 为什么我会得到android.database.sqlite.sqlitecursor@error,java,android,sqlite,Java,Android,Sqlite,每当我试图显示nexpdate的值时,就会得到null值。我得到以下错误:android.database.sqlite.sqlitecursor@ // insertion of values in renew table public void insertrenew (String rcode, String nexpdate) { SQLiteDatabase db = this.getWritableDatabase(); Conte
// insertion of values in renew table
public void insertrenew (String rcode, String nexpdate) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("rcode", rcode);
contentValues.put("nexpdate", nexpdate);
db.insert("renew", null, contentValues);
}
//java code to get the value of nexpdate
public String getrenew (String rcode) {
SQLiteDatabase db = this.getReadableDatabase();
String selectQuery = "SELECT nexpdate from renew where rcode = " + rcode;
String cursor = String.valueOf(db.rawQuery(selectQuery, null));
return cursor;
}
我假设您遇到了一个错误:
android.database.sqlite.sqlitecursor @ XXXX // where XXXX indicates object code
原因/详情:
这里的原因是您直接将游标
对象投射到字符串
中,这就是问题所在
String cursor=String.valueOf(db.rawQuery(selectQuery,null))代码>
仅供参考,rawQuery()
方法实际返回Cursor
值,我们需要遍历Cursor以获得所需的数据。有关从光标获取数据的更多详细信息,请参阅。您能分享您获取的确切错误吗?检查logcat输出并在此处共享。