2

In my android application I have to store some application settings and some user information within the phone.

I can go for the shared preference option explained in this DOCUMENTATION.

But wondering if I can store data as objects wise within the phone. I found this Stackoverflow Question regarding saving serialized objects in files and bit not sure of any issues if I go with this way to store persistent data.

Also would like to know what the best way to deal with insert/delete/update and read with XML files in android. Would appreciate any guidance. Thanks in advance...!!!

Community
  • 1
  • 1
JibW
  • 4,538
  • 17
  • 66
  • 101

2 Answers2

1

If you want to persist some objects I think you should use SQLiteDatabase, it would be a more cleaner solution than using serialization in files. You will indeed need to write some extra code for your Database but you will end up with a cleaner implementation in my opinion. You could also be using OrmLite for Android which is pretty robust and easy to use if you have some basic orm knowledge.

Ovidiu Latcu
  • 71,607
  • 15
  • 76
  • 84
  • Hi Ovidiu Latcu, Thanks. In my scenario I just dont have that much data. just few objects. Do you think still its worth while for go for a database solution? Also they are don't have a clear relationship to devide in to tables with foreign keys and all. Do you think its better to go for a XML solution? – JibW Oct 26 '12 at 09:51
1

If it is only a small amount of data you need to store, then go with the built-in shared preferences, that is what the functionality is there for. SQLite and OrmLite are a bit heavyweight in this situation IMO. Even if you want to handle the data as Objects; in which case I would serialise to / deserialise from JSON or XML stored in text files and handle the insert/update/delete on the deserialised objects in your model.

paulkayuk
  • 1,052
  • 1
  • 8
  • 15
  • HI paulkayuk, what method do you think is the best to write, delete and update data with xml files in the android internal storage. Thanks – JibW Nov 05 '12 at 16:54