-2

In my android application, user need to load about >100 rows populated in a Listview. To update new data everyday without updating app, I store my data in a XML file, put it in server and when user open app, my app load new XML file from server and parse them into my Listview.

Does my practice is a good method? How about it performance compare to JSON? And when I need to use MySQL server?

Quan Nguyen
  • 5,074
  • 3
  • 24
  • 26
  • Its better if you store your xml parse data into sqlite Database and retrieve data fro there as it will reduce the network dependencies when the app is offline and it will save battery as it will not call web service every time the list need to be populated – Sanjeev Jul 17 '15 at 17:18

3 Answers3

1

Your approach is fine but JSON would be a bit better because it is more compact. Refer this answer: JSON and XML comparison

To cache your data use SQLite database, it will be much faster to read data from database on your device than making a network request.

Community
  • 1
  • 1
Gennadii Saprykin
  • 4,505
  • 8
  • 31
  • 41
  • Sorry I forgot to say that I need to update data everyday/week without updating app. So maybe JSON is a good choice. Thanks !!! – Quan Nguyen Jul 19 '15 at 17:10
1

This is a static approach. You must edit the XML yourself every time you want to change the result.

A dynamic approach would make you create a database to store the data (MySQL or any other) and you would write a script that communicates with the database and query for data and then you need there to choose between the formats XML or Json. I think Json is faster and more readable than XML and JSON is also more compact.

Ahmed Hegazy
  • 12,395
  • 5
  • 41
  • 64
0

You can use Protocol Buffers

According to the site:

Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.

Benefits of Protocol Buffers:

Protocol buffers have many advantages over XML for serializing structured data. Protocol buffers:

are simpler
are 3 to 10 times smaller
are 20 to 100 times faster
are less ambiguous
generate data access classes that are easier to use programmatically
Community
  • 1
  • 1
rupesh jain
  • 3,410
  • 1
  • 14
  • 22