解决方法 1:
不应该是用单独的语句,你不应该用单独的sql语句?
只是创建一个ArrayList,在这个activity类中存储所有需要的数值。
例如: ArrayList myData;
现在在数据库类的帮助下写一个function,就像下边:
//得到你想要的数据
public ArrayList<String> getAllData() {
ArrayList<String> subTitleList = null;
Cursor cursor = null;
try {
String queryString = "SELECT FROM champions";
cursor = dbrawQuery(queryString, null);
if (cursor != null && cursormoveToFirst()) {
subTitleList = new ArrayList<String>();
do {
String nextUser = new String(cursorgetString(cursorgetColumnIndex("name")));
String nextUser = new String(cursorgetString(cursorgetColumnIndex("title")));
String nextUser = new String(cursorgetString(cursorgetColumnIndex("thumb")));
subTitleListadd(nextUser);
}
while (cursormoveToNext());
Systemoutprintln("it comes in SubTitleList");
}
}
catch (Exception e) {
eprintStackTrace();
subTitleList = null;
}
finally {
if (cursor != null && !cursorisClosed()) {
cursordeactivate();
cursorclose();
cursor = null;
}
if(db != null){
dbclose();
}
}
//Systemoutprintln("SubTitleList is: "+subTitleList);
return subTitleList;
}
现在在你的activity类中你可以调用这个方法,然后从myData ArrayList获得所有你需要的数据。
1
myData = dbgetAllData(); // 我想如果你想要抓所有的数据的话是不需要ID的。
希望你能明白
1,
"show
tables"
in
sqlite命令行模式schema
抓出数据库中所有的表tables
抓出数据库中所有的表和索引都可以使用LIKE来匹配程序中使用sqlite中的sqlite_master表来查询sqlite_master表结构CREATE
TABLE
sqlite_master
(
type
TEXT,
name
TEXT,
tbl_name
TEXT,
rootpage
INTEGER,
sql
TEXT);查询table,type
段是'table',name段是table的名字,
so:select
name
from
sqlite_master
where
type='table'
order
by
name;查询indices,type段是'index',
name
是index的名字,tbl_name是index所拥有的table的名字2"describe
table"两种方法-cursorexecute("PRAGMA
table_info(tablename)")print
cursorfetchall()--from
sqlite3
import
dbapi2
as
sqlitecurexecute("SELECT
FROM
SomeTable")col_name_list
=
[tuple[0]
for
tuple
in
curdescription]
查询table,type 段是'table',name段是table的名字, so:
select name from sqlite_master where type='table' order by name;
查询indices,type段是'index', name 是index的名字,tbl_name是index所拥有的table的名字通过以下语句可查询出某个表的所有字段信息
PRAGMA table_info([tablename])
如果在程序中你可以通过 sqlite_master 表得到所有表的信息。
列出数据库的全部表名
select name from sysobjects where type='u'
select count() from sysobjects where id = object_id('数据库名Owner表名')OBJECT_ID返回数据库对象标识号。
语法OBJECT_ID ( 'object' )参数'object'要使用的对象。object 的数据类型为 char 或 nchar。如果 object 的数据类型是 char,那么
隐性将其转换成 nchar。
返回类型int注释当该参数对系统函数可选时,则系统采用当前数据库、主机、服务器用户或数据库用户。内
置函数后面必须跟圆括号。
如果指定一个临时表名,则必须在临时表名前面加上数据库名,例如:
SELECT OBJECT_ID('tempdb#mytemptable')
系统函数可以在选择列表、WHERE 子句和任何允许使用表达式的地方使用。有关更多信
息,请参见表达式和 WHERE。
示例下面的示例为 pubs 数据库中的 authors 表返回对象 ID。
USE masterSELECT OBJECT_ID('pubsauthors')
下面是结果集:
以上就是关于在android中从sqlite中获得数据很慢怎么解决全部的内容,包括:在android中从sqlite中获得数据很慢怎么解决、在程序里怎么取得sqlite数据库里所有的表名、SQLLite数据库获取一个表有多少列的语句是什么等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)