views:

620

answers:

4

Hi.

I am trying to fetch sms messages from inbox, sent items and drafts. I would like to do a pagination for my list view for that it's imperative that I fetch records in pages/chunks.

I am not familiar with sqlite which is the database I understand android use to store the data. Can someone tell me how can I restrict the number of records I am fetching by using contentResolver.query?

Also what is the way to pull the sqlite database file onto my machine and browse/query it locally to experiment or see data on my machine?

Are there any other better ways to implement pagination in android??

Thanks

+5  A: 

According to the Sqlite website, you can use a LIMIT ... OFFSET ... clause in your query:

http://www.sqlite.org/syntaxdiagrams.html#select-stmt

Rich
This is what I use too - LIMIT. SELECT * from mytable LIMIT 100
Brad Hein
+1  A: 

These should help you
http://osdir.com/ml/Android-Developers/2010-03/msg04308.html
http://groups.google.com/group/android-developers/browse_thread/thread/b355f032064b7571

zapping
The second one of those in particular has lots of good info.
Jim Kiley
I select this as the correct answer as second link indeed gives a deep insight of some intricacies of android cursor and database objects and their roles. This enabled me to form my view more clearly of layers that we have in android. Unfortunately it still doesn't solves my problem. :)
Priyank
I realized, that maybe it's CursorAdapter that I am looking for as pointed out by @alexanderblom. :) Thanks for excellent info still! :)
Priyank
+1  A: 

To pull your database for viewing, make a copy of it on the SD card and then use adp pull to get it.

Brad Hein
+1  A: 

There doesn't seem to be any way to limit your results from the SmsProvider. However you shouldn't really need to, given that you use CursorAdapter and don't try to read the contents into your own data structures. Have you tried this?

alexanderblom
can you please point me to some examples of as to how CursorAdapter is used?
Priyank
This has a good one http://thinkandroid.wordpress.com/2010/01/11/custom-cursoradapters/
zapping