What is the fastest way to load 10,000 rows from a SQLite database into memory? Each row has 1 text and 4 integers. Currently, I'm doing this:
while(!cursor.isAfterLast()) {
cursor.copyStringToBuffer(column_index_1, buffer);
cursor.copyStringToBuffer(column_index_2, buffer);
cursor.copyStringToBuffer(column_index_3, buffer);
cursor.copyStringToBuffer(column_index_4, buffer);
cursor.copyStringToBuffer(column_index_5, buffer);
cursor.moveToNext();
}
The above code takes about 750 ms on Galaxy Nexus. On older devices it could be couple of times slower. Can I make it faster?
(At this point, you're probably typing something like "Why do you need to load the rows into memory?" It's a bit complicated but I can try to explain if someone's interested. Edit: here's the explanation: https://gist.github.com/fhucho/af355d56ae3145e3e30f)
First i advice you to load only the first 1000 rows, and then Use AsyncTask to load more.
You can find response here http://www.javasrilankansupport.com/2012/11/asynctask-android-example-asynctask-in.html
Hope this help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With