1

Putting cursor data into an array

view story
linux-howto

http://stackoverflow.com – Being new in Android, I am having trouble dealing with the following: public String[] getContacts(){ Cursor cursor = getReadableDatabase().rawQuery("SELECT name FROM contacts", null); String [] names = {""}; for(int i = 0; i < cursor.getCount(); i ++){ names[i] = cursor.getString(i); } cursor.close(); return names; } The following gives me the following error: 09-18 10:07:38.616: E/AndroidRuntime(28165): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sqllitetrial/com.example.sqllitetrial.InsideDB}: android.database.Curs (HowTos)