Binding data in Android
I have following scenario. There is OrderHeader and OrderDetail tables in SQLLite database. I have Activity where I want to display that data. There is number of fields...
The way I see it - it has to be like this:
- Get data from my content provider (I have it).
- Get ordinals for columns in cursor.
- Get values from cursor and format/assign them
Like I said - there is MANY fields and writing this kind of code (especially #1 and #2) very tedious and boring :)
So, I've got this idea.. Since my data comes in as JSON to begin with (from web) - I can store original JSON presentation in database along with parsed-out data and when I need to bind - all I need is to query table for this column and deserialize with GSON. This way - #1 and #2 will be 3 lines instead of many. And I will work w开发者_StackOverflow中文版ith POJO...
Does that sounds good or there is natural nice way to bind views to data from database?
Use a ListView and a SimpleCursorAdapter (or extend it).
精彩评论