If you want to get information in an array (or any structure that you can iterate over rows), you can make a method such as:
public String[] getDBNames(){ String[] result; try { StringBuilder sb = new StringBuilder(); sb.append("SELECT name FROM sqlite_master "); sb.append("WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' "); sb.append("UNION ALL "); sb.append("SELECT name FROM sqlite_temp_master "); sb.append("WHERE type IN ('table','view') "); sb.append("ORDER BY 1"); Cursor c = _db.rawQuery(sb.toString(), null); c.moveToFirst(); result = new String[c.getCount()]; int i = 0; while (c.moveToNext()) { result[i]= c.getString(c.getColumnIndex("name")); i++; } c.close(); } catch(SQLiteException e){ Log.e("OOPS", e); } return result; }
source share