0

I get null value whenever I try to display the value of nexpdate. I get the following error android.database.sqlite.sqlitecursor @ .

  // 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;

        }
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295

1 Answers1

0

I assume you are getting an error:

android.database.sqlite.sqlitecursor @ XXXX // where XXXX indicates object code

Reason/Details:

Reason being here is you are directly casting Cursor object into the String and that's where an issue is!

String cursor = String.valueOf(db.rawQuery(selectQuery, null));

FYI, rawQuery() method actually returns Cursor value and we need to iterate through the cursor actually to get the needed data. You may refer How to retrieve data from cursor class for more details on getting data from the Cursor.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295