dimanche 3 avril 2016

Concatinating Strings or saving them each one on its own row in a separated table

In an Android app, I have a RecyclerView. the data which is shown in each row of that RecyclerView is from an objects of a class which has an ArrayList of Strings as one of its fields. the data of the objects is saved on a database. what is the better way to save the Strings of that ArrayList in the database according to the performance of the app:

Make a concatenated String from the Strings by concatenating them to each other with a separator, then save that concatenated String in a row in a table. So, the data of the whole object will be saved in one row. When I want to create the object I query the table and get the concatenated String from the cursor then I tokenize it and create the ArrayList.

OR

Make a separated table and save every String in its own row. So the data of the object is saved in one row except the those Strings which will be saved multiple rows in a separated table. When I want to create the object I query the table which have the object data then for each row of that table I query the Strings table for the Strings of the ArrayList, then I create the ArrayList from the returned Strings of the cursor of the Strings table.

According to the performance, what is better?

Aucun commentaire:

Enregistrer un commentaire