Dariel Pratama Dariel Pratama - 10 months ago 45
Java Question

Is it good to have a fixed data stored in JSON instead of SQLite

i am new to Android, and currently i am developing my own app (for learning).
question is, is it good to store fixed data in form of JSON instead of SQLite (i won't update data at all), i have tried store it in HashMap which is not so good i think.

current code in HashMap is

HashMap<Integer, String[]> data = new HashMap<Integer, String[]>();
data.put(1, new String[]{"asd", "cax", "etc", "etc"});

thanks in advance

Answer Source

Since your data looks like an array of strings, one idea is to use Android's built-in resource system.

You can store your data in an XML file called res/values/arrays.xml, for example as follows:

    <string-array name="planets_array">

In your code, you can access to the array as follows:

Resources res = getResources();
String[] planets = res.getStringArray(R.array.planets_array);

You can find more information from the links below.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download