I've came to Android from Java.
I used there, with successes, Serialization mechanizm to keep data in file (mainly to avoid of using additional software like MySQL DB). Mark-up of input-output operations of serialization was easily acceptable on PC (in my particular case it took two - three seconds).
But in Android, serialization of the same bunch of data takes much more time (especially under eclipse emulator which is terribly slow - yes i know there is Genymotion).
Are there any alternatives of ser/deser between file and aplication?
I've heard about Parcelable (but AFAIK this should be use rather to transport data between applications).
Maybe is there something else? Code amount needed to implement and difficulty has no matter. I need speed.
Asked
Active
Viewed 522 times
1

rainbow
- 1,161
- 3
- 14
- 29
-
1use builtin sqlite support – pskink Apr 11 '14 at 06:29
-
Using of DB isn't idea of this question. – rainbow Apr 11 '14 at 06:59
-
if you need speed this is what you need, and if you are not aware: sqlite is not an additional software – pskink Apr 11 '14 at 07:20
-
I have to clarify your advice. Is your proposition to put data to DB instead to serialized file? Is such "sqlite" is present in every version of Android and it is backward compatible? – rainbow Apr 11 '14 at 07:28
-
1http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html Added in API level 1 – pskink Apr 11 '14 at 07:30
-
Thank you, it can be a good direction. – rainbow Apr 11 '14 at 07:31
1 Answers
1
The alternative to serialization is custom serialization :) You can use JSON (with the GSON library), XML with XMLSerializer, etc. You can also use some form ORM (manual or with ORMLite, etc.) to store data in a database, as has been suggested. What you should use depends on what kind of data and how large you are trying to serialize. BTW, Parcelable
is used for IPC, it's not meant for persistence.

Nikolay Elenkov
- 52,576
- 10
- 84
- 84