Data format
The JavaScript Object Notation (JSON) is widely used in transferring data over the net
Storage
That depends on what you're trying to do - if the data is only temporary in nature, what you're suggesting works. If it needs to be stored across application starts, you will need some kind of persistence. A database would be one way to do that.
Remember though, that if you place your data loading code in your activity's onCreate
or onResume
method (or anywhere in startup callbacks of the activity lifecycle), it will get loaded everytime your activity is created - even if the user just flipped the device. If the data takes long to load (which over the network can always be the case, even if it's just a few bytes), this can result in very bad user experience.
One way to deal with this would be using a custom Loader, which can exist separate from your activity and would be able to cache your previously loaded data.
Conceptually, doing this would require you to extend Loader
, and override the onStartLoading
method to begin loading your data from the network. You should probably also override onStopLoading
and onCancelLoad
to keep your app from needlessly shoveling data over the connection even if it's not wanted anymore.
Having done this, you would provide LoaderCallbacks
(as shown in the link I gave you), and instead of creating a new CursorLoader
in the onCreateLoader
callback, create an instance of your own custom loader class.