Android获取表格列表
有人知道在Android中通过代码获取表名列表的SQL吗?我知道Android获取表格列表,android,database,Android,Database,有人知道在Android中通过代码获取表名列表的SQL吗?我知道.tables是通过命令shell实现的,但这不能通过代码实现。这与元数据等有关吗?明白了: SELECT * FROM sqlite_master WHERE type='table' 我也不得不这么做。这似乎有效: public ArrayList<Object> listTables() { ArrayList<Object> tableList = new ArrayList
.tables
是通过命令shell实现的,但这不能通过代码实现。这与元数据等有关吗?明白了:
SELECT * FROM sqlite_master WHERE type='table'
我也不得不这么做。这似乎有效:
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;
}
publicArrayList listTables()
{
ArrayList tableList=新的ArrayList();
字符串SQL\u GET\u ALL\u TABLES=“从中选择名称”+
“sqlite_master,其中type='table'按名称排序”;
Cursor Cursor=db.rawQuery(SQL\u GET\u ALL\u表,null);
cursor.moveToFirst();
如果(!cursor.isAfterLast()){
做{
tableList.add(cursor.getString(0));
}
while(cursor.moveToNext());
}
cursor.close();
返回表格列表;
}
如果我将此表列表打印到日志中,怎么可能?