Strategies for data management

kanaida

Active Member
Licensed User
Longtime User
I want to know what kind of way would be the easiest to maintain, and write the least amount of code to populate views, and load/store data.

I mostly write business applications, order entry, inventory, etc... so I have a lot of experience with asp.net web services and winforms, async web service calls, datasets, tables, sql and databases.

Typically I do the following:
Make a Dataset inside a class
Create a class for the result in with the same properties that i will add to say a listview.
A web service method, that gets the data using the dataset, and returns ListViewItems (my web service class, with values filled in)

In B4A I make a simple http request
parse the xml result, as I parse I Add items to the listview.

This isn't really a generic way of handling things though. What I mean by that, is if there's some sort of way to generically databind things to controls.

Something like:
ListView1.Label_DataProperty = "Name"
ListView1.SecondLabel_DataProperty = "Description"
ListView1.Value_DataProperty = "PersonId"
ListView1.DataSource = SomeInputStream 'Xml probably

Then being able to access the DataSource Property, Maybe save the datasource -> sdcard as an xml file, so if your activity restarts it will load that instead of a new http call.

I'm not sure if the same databinding concepts really apply here, and I know I can do lots of this stuff with global variables, I'm looking more for best practices and techniques that may exist that i'm not aware of. Just like in vb.net you can do things the long way, or see if there's already classes or something in place that can aid you more easily accomplish the same task and keep your code tidy. Usually the first thing I'll do is try to make a small framework to do all the plumbing work in a generic way so that I never have to deal with it anymore.

I see the DBUtils looks interesting. I think something like that but for XML would be helpful. Just wondering what avenue everyone else finds clean and simple.
 
Last edited:

kanaida

Active Member
Licensed User
Longtime User
Thanks

Yes, I did look at SQLite and the tutorial. Also the dbutils.
After looking at it, i realized it's basically the same thing that i'm currently doing except I use asp.net web services as my "server".

What i'm finding is that although it's not exactly a "class", creating a type, then a list that holds items of that type goes a long way. Now I can set the .Value of a listview as a type object from my array and get the rest of the properties. It's the replacement for a datatable that holds rows, sort of. The hardest part was wrapping my head around changing things like label text on items in a list view, if there was no .Items() property. I think that property alone, added to the Listview, and other containers that can hold views would help newcomers adjust much more quickly. The other thing that would help is a Panel.AddViewToBottom(v as view), so we don't have to figure out "top" and "left" manually in loops. It would work like adding items in the list.

Well at least now that I got the hang of types, I can just dump them to the SQLite db for caching. Thanks.
 
Upvote 0
Top