dimanche 15 février 2015

How to store a single row data into a string array of sqlite database in android

I have called a function returnCurrentNameById() by passing the id of the particular row. But it gives an error.



String[] s1;

public String[] returnCurrentNameById(int k) throws SQLException{

String[] columns = new String[]{ KEY_ID1, KEY_NAME, Key_DOB, KEY_AGE, KEY_PHONE_NO, Key_EXPERIENCE, KEY_EMAIL, KEY_STATUS, KEY_STATUS};
SQLiteDatabase db3 = this.getReadableDatabase();
Cursor c = db3.query(DATA_BASE_TABLE_NAME1, columns, KEY_ID1 + "=" + k, null, null, null, null);

if (c != null){
c.moveToFirst();
for(int i = 0; i<=8; i++){
s1[i] = c.getString(i);
}
return s1;
}
return null;
}

Aucun commentaire:

Enregistrer un commentaire