Limited Records Uploaded to Android (Sqlite Database)

I am trying to get sms messages from incoming messages, sent items and drafts. I would like to do pagination for my list, because I need me to write records on pages / chunks.

I am not familiar with sqlite, which is a database that I understand is using android to store data. Can someone tell me how can I limit the number of records I get using contentResolver.query?

Also how to pull sqlite database file to my machine and view / query it locally to experiment or see data on my machine?

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

thanks

+4
source share
4 answers

There seems to be no way to limit your results from SmsProvider . However, you should not do this, given that you are using the CursorAdapter and are not trying to read the contents in your own data structures. Have you tried this?

+1
source

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

+8
source

For those who stumble upon this answer, looking for a way to use the LIMIT with OFFSET , I learned from this error that Android uses the following regular expression to parse the limit clause:

In the framework of /base/core/java/android/database/sqlite/SQLiteQueryBuilder.java:

The LIMIT clause is checked using the following sLimitPattern parameter.

 private static final Pattern sLimitPattern = Pattern.compile("\\s*\\d+\\s*(,\\s*\\d+\\s*)?"); 

Note that the regular expression accepts the format offsetNumber,limitNumber , even if it does not directly accept the OFFSET statement.

+5
source

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

+1
source

Source: https://habr.com/ru/post/1307683/


All Articles