im currently porting my iphone app to android. this app makes heavy use of sqlite data. on the iphone i populate my custom objects with sqlite data, open and close my connection to the database multiple times on demand
however on the android, i have not come across many tutorials which follow this approach. they simply use a cursor and show the data directly without making use of custom objects and collections
i wanted to know if the开发者_如何学运维re was any particular reason for this on the android? what would you suggest me to here? ie: is it feasible to have an always on connection / cursor the the sqlite db on the android and display the data directly OR go the iphone way that is to populate collection of custom objects from sqlite and have the UI data bound to this collection instead of the sqlite cursor
thanks in advance folks
I don't think optimal approach will vary with platform to any significant degree.
- Sqlite keeps caches in the connection, so it's usually advantageous to keep the connection open.
- You can save some time by preparing the statements once and reusing them.
- Query startup is quite significant, so join everything you will need in one query. Getting a list of objects in one query and than starting separate queries for individual objects is very slow compared to join statement.
- If you can populate the UI objects directly from the database, going through any intermediate objects is just putting unnecessary load on the memory manager (whether ga
精彩评论