Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

android - Sqlite Get x rows, then next x rows

Im developing android app, which use SQLite database.

I have ListView which uses data from Database to show a list (see picture).

The picture is decoded in Base64 String and stored in Database. My problem is this Log:

10-19 16:51:36.612: W/CursorWindow(15151): Window is full: 
requested allocation 136877 bytes, free space 78836 bytes, window size 2097152 bytes

It skypes a lot of Frames, because the read time grows. This is because i read always x+10 rows. 1st, it reads 10 rows, then 20, then 30 and go on...

The solution, what i want to use is, get rows from 0-10, 11 - 20, 21 - 30 and so on. How to achieve this? I just need the Sql query.

EDIT: my query

String columns[] = {KEY_ID, KEY_NAME, KEY_RATING, KEY_CUISINE, KEY_IMAGE};
Cursor cursor = db.query(TABLE_RECIPES, columns, null, null, null, null, KEY_NAME, lim);

ListView

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the rawQuery method, and specify the limit keyword.

e.g.:

"SELECT * FROM myTable limit 10" <-- get the 1st 10 rows
"SELECT * FROM myTable limit 10, 20" <-- get the 2nd 10 rows between 10 and 20, etc

This should get you started.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...