Android Get List Of Tables
Does anyone know the SQL to get a list of table names via code in Android? I know .tables does it through command shell but this doesn't work through code. Is it anything to do wit
Solution 1:
Just had to do the same. This seems to work:
publicArrayList<Object> listTables()
{
ArrayList<Object> tableList = newArrayList<Object>();
StringSQL_GET_ALL_TABLES = "SELECT name FROM " +
"sqlite_master WHERE type='table' ORDER BY name";
Cursor cursor = db.rawQuery(SQL_GET_ALL_TABLES, null);
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
do {
tableList.add(cursor.getString(0));
}
while (cursor.moveToNext());
}
cursor.close();
return tableList;
}
Solution 2:
Got it:
SELECT*FROM sqlite_master WHERE type='table'
Post a Comment for "Android Get List Of Tables"