有没有人知道SQL通过Android中的代码获取表名列表?我知道.tables它是通过命令shell实现的,但这不能通过代码实现.它与元数据等有什么关系吗?
Giu*_*sco 10
只是不得不这样做.这似乎有效:
public ArrayList<Object> listTables()
{
ArrayList<Object> tableList = new ArrayList<Object>();
String SQL_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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3563 次 |
| 最近记录: |