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

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


You have not initialized your s1 array.

Use

s1 = new String[9];

to allocate an array of 9 elements.

Also check the return value of moveToFirst() so you don't get an exception in case the query returns no rows.


Replace

 Cursor c = db3.query(DATA_BASE_TABLE_NAME1, columns, KEY_ID1 + "=" + k, null, null, null, null);

with

 Cursor c = db3.query(DATA_BASE_TABLE_NAME1, columns, KEY_ID1 + " = ?", new String[]{String.valueOf(k)}, null, null, null);