lundi 9 novembre 2015

Best practise to store key-value data in Android

Today I have faced such situation: In my SQLite DB I have TASK_TABLE which stores some information about user tasks, and I need to bring in a new field, which is single for all tasks.

So, my question is, what are the best practises to store such fields (I guess, in future threre will be more). Should I create something about key-value table, or maybe I should use shared preferences, which is a built-in key-value storage in Android. The option with shared preferences in my opinion is less attractive, because field, which belongs to "TASK" entity (which stores in db) should be stored far away from it, somewhere in xml file... Also, in my mind, shared preferences is something that is prefered choise to store every kind of configurations. But at the same time shared preferences is built-in key-value store mechanism.

P.S. There is one more option, with single row table, but i didn't consider it, because I don't want to update schema every time I add a new value.

Aucun commentaire:

Enregistrer un commentaire