I'm developing an Android app which displays a list of objects. For each object displayed I populate several textviews with information stored in strings members.
The information is stored in separate xml files with the following format:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://ift.tt/nIICcg">
<string-array name="Object_Name">
<!-- Atribute 1 -->
<item ></item>
<!-- Atribute 2 -->
<item ></item>
<!-- Atribute 3 -->
<item ></item>
<!-- Atribute 4 -->
<item ></item>
<!-- Atribute 5 -->
<item ></item>
<!-- Atribute 6 -->
<item ></item>
<!-- Atribute 7 -->
<item ></item>
<!-- Atribute 8 -->
<item ></item>
<!-- Atribute 9 -->
<item ></item>
</string-array>
</resources>
I have thought of two ways to handle this the information in my app:
When the application starts, I create a list of objects and for each
</string-array>
I have defined in my xml files. I store in the object members the strings from the<item>
. There are around 250 such objects and some of the attributes contain large strings(1000 characters or more). Every time the textviews need to be populated I read the strings from the objects with getter methods.When the application starts, I create a list of objects and for each
</string-array>
I have defined in my xml files. I store the resource id for the</string-array>
but don't read any attribute. Every time the textviews need to be populated, I read the attributes from the xml associated with the object and return the strings.
The first method impacts the app startup because it takes a bit of time to populate the list of objects with the information from the array but has the benefit of speed once the list is created. Also all those strings might need quite a bit of memory and memory is a precious resource on smartphones.
The second method will reduce the app startup and use less memory for the list of objects, because only resource id's are stored. The drawback I see is that every time the textviews are created and populated, the contents is read from the xml files. I assume that reading from the storage medium, takes longer time and might make the app feel sluggish to the user.
Is my analysis of the two methods correct or not?
Which method do you think I should use and why?
Are there some tools that I can use to measure runtime and memory usage?
No comments:
Post a Comment