Im working on a new project to learn android programmation.
So I want to know how can I handle data between Activity.
I have a MainActivity which parse a remote XML file and put all parsed data in a List
Moreover MainActivity displays a list of all MyData, and if I click on an item it’s start my DetailActivity.
But now I use a putExtra with a Parcelable of the MyData item to display datas (only text).
So I want to know if it’s the right way ?
And I’ve another question.
In MainActivity I handle one remote XML file, but if I have an activity SecondActivity which handle a second remote XML file.
How can I do to download these two files only once, to avoid many download when I switch between MainActivity and SecondActivity.
Thanks
Save the files to the phone to avoid repeat downloads. Just check for the existence of the file and if it’s not there, download and save it. As for passing data between activities, the Intent’s putExtra method is the correct method. I prefer serializable to parcelable, but that may be because parcelable is harder to implement.
For a simple example of the putExtra method, please look here:
StackOverflow answer