0

I want my application to use manually created string data. For example:

Title1 : Description1
Title2 : Description2
Title3 : Description3

There will be a long discription, such as termonology of smth. And i want to import this data to my android app. I read about some options, such as: SQLite, JSON. But i cannot understand, how should i do this. Just move my file.db or file.json to assets folder or how ?

There are in my data maximum 100 terminologies with description.

Rarity7-
  • 187
  • 1
  • 11

1 Answers1

0

You can create your json file like this:

[
{
    "Title": "Some title",
    "Description": "Some Description"
}, {
    "Title": "Some title1",
    "Description": "Some Description1"
}, {
    "Title": "Some title2",
    "Description": "Some Description2"
}, {
    "Title": "Some title3",
    "Description": "Some Description3"
}, {
    "Title": "Some title4",
    "Description": "Some Description4"
}
]

and store it in asset folder. On initial launch of your application you can check whether data is present in SQLite database or not if its not then you can Parse JSON from assets.

Convert it into

JSONArray arr = new JSONArray(jsonString);

then you can add each title and description into the SQLitedatabase Insert data into SQLITE by iterating over this JSONArray

Deepak S. Gavkar
  • 447
  • 8
  • 21