Android的sqlite的节目表 [英] Android sqlite show tables
本文介绍了Android的sqlite的节目表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以查询表的列表在数据库中到游标?我不知道如何实现在Android中显示表的方法。
一种方法是将所有的表存储在一个收藏家表作为记录,但,这是一个解决办法。
Is it possible to query the list of tables in a database into a Cursor? I don't know how to implement the show tables method in android. One way is to store all tables in a "collector" table as records but this is a workaround.
P.S:我不需要只是那些开始PR_的所有表(我知道如何在查询中处理这个问题,我不知道是,如果在这种情况下事项)
P.S: I don't need all the tables just the ones starting with "PR_" (I know how to handle this in queries, what I don't know is if that matters in this case).
推荐答案
我找到了解决办法。
在SQLiteOpenHelper类:
I found the solution. In the SQLiteOpenHelper class:
public Cursor showAllTables(){
String mySql = " SELECT name FROM sqlite_master " + " WHERE type='table' "
+ " AND name LIKE 'PR_%' ";
return ourDatabase.rawQuery(mySql, null);
}
在活动:
Cursor c = info.showAllTables();
if (c.moveToFirst())
{
do{
todoItems.add(c.getString(0));
}while (c.moveToNext());
}
if (todoItems.size() >= 0)
{
for (int i=0; i<todoItems.size(); i++)
{
Log.d("TODOItems(" + i + ")", todoItems.get(i) + "");
}
}
这篇关于Android的sqlite的节目表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文