1

My issue is this: I am making a few activity screens that requires the use of some parts of information from all 3 Xml files. The problem comes when after parsing the xml's, I am stumped on what kind of object to store them with, to reduce the performance hit when running on the android phone, as I wish to support back to 2.2. (See below for the XML's) To complicate things more, "a" can have many "b"s, which in turn can have many "c"s. This results in about 12b's per a, and 20c's per b.

I could create an object per activity able to store everything that one activity needs, storing only the necessary parts of information from the XML's needed by the activity in arrays and 2d arrays if necessary. That way, less objects would be created but more time would be taken re-parsing when moving between activities.

I could also create an array of the necessary objects(a,b or c. Possibly 3 arrays of a,b, AND c), populated by the parser. This would be effectively simpler to code, since its more direct. Much easier to maintain as well, I would suppose. However, I am predicting a performance hit that I would probably..not like.

So heres the thing, is the performance hit small enough to forgo the necessity of creating a specialised object for each activity? Especially performance wise, in terms of load times and memory usage.(Since we are on the mobile here!)

Opinions, anyone?

The use of XML's are fixed, as is their format. They are local.
Using a XMLPullParser to retrieve their information.

My Xml(I have 3 of these; a,b & c):

<aType>
   <aRecord>
      <a1>SomeText</a1>
      <a2>SomeText</a2>    
   </aRecord>
   ...
</aType>
David Bejar
  • 512
  • 4
  • 20
  • Take a look here: http://stackoverflow.com/questions/4878159/android-whats-the-best-way-to-share-data-between-activities and here: http://stackoverflow.com/questions/4272906/sharing-an-object-between-activities. – Artyom Sep 18 '12 at 12:56
  • Okay, I gave both a read. 2nd one was interesting in that it says about variables that are used across many activites, which may come in handy as well. The first one talks about passing variables around too. Moving around in activities is manageable, since its mostly passing a single selection.(Sorry if I didnt say that!) More concerned about the performance hit on a single activity when loading up instead, since the activities have alot to load individually. – user1667600 Sep 18 '12 at 13:25

0 Answers0