【发布时间】:2018-07-17 08:10:24
【问题描述】:
我如何执行检索 2 个字符串和 1 个整数值的选择语句。我收到此错误。我的应用程序一直在 cursor.getString(0);在我的日志中,我确实收到了这条消息 Log.d("TAG","Row found");
Login.java
private void getQRCodeInformation(){
//database helper object
DatabaseHelper db;
//initializing views and objects
db = new DatabaseHelper(this);
Cursor cursor = db.getQRCodeInformation();
if(cursor.getCount() == 0) {
Log.d("TAG","Nothing found");
}
else{
Log.d("TAG","Row found");
if(cursor != null && cursor.moveToFirst()){
//cursor.getString(0);
//cursor.getString(1);
//cursor.getInt(1);
Log.d("TAG","Data found");
}
}
}
DatabaseHelper.java
public Cursor getQRCodeInformation(){
SQLiteDatabase db = this.getReadableDatabase();
String sql = "SELECT "+COLUMN_0_UserDetail+" , "+COLUMN_4_UserDetail+" , "+COLUMN_5_UserDetail+ " FROM "+ TABLE_NAME_UserDetail;
Cursor c = db.rawQuery(sql, null);
return c;
}
【问题讨论】:
-
我已经评论 cursor.getString(0) 来检查我的日志
标签: android sql sqlite android-sqlite