Android Store a Parcelable Object in SQLite

I need to store an object content in Sqlite.
I was wondering which was the best way to do it with a serialization of the object or with Parcelable.

Is it possible to store it as Parcelable? How can I do it?

  • How to generate an MD5 checksum for a file in Android?
  • google play warns about added permission 'android.permission.READ_CALL_LOG'
  • Multiple android.intent.action.MAIN in mainfest xml file
  • Is this a correct way to use Dagger 2 for Android app in unit test to override dependencies with mocks/fakes?
  • how to use free cloud database with android app?
  • How to stop debug without closing app in Android Studio 2
  • Related posts:

    Check for access to notifications using NotificationListenerService
    How can I post on Twitter with Intent Action_send?
    How to debug specific build variant of Android Gradle project in IntelliJ IDEA?
    How to Record Voice in android?
    How facebook measure app installs - Android/IOS
    Use SIM card slot as a smart card reader in Android phones
  • Extended SurfaceView's onDraw() method never called
  • How to avoid SQLiteException locking errors
  • Use android.R.layout.simple_list_item_1 with a light theme
  • android custom view attributes not working after switch to gradle
  • How to set Java SDK path in AndroidStudio?
  • Bring Google Map Markers to Front by Changing Z-Index in Android
  • 2 Solutions collect form web for “Android Store a Parcelable Object in SQLite”

    You are welcome to convert your object into some sort of persistable data structure (XML, JSON, Serializable) and stuff it in some database column. Bear in mind that you will still need to deal with compatibility issues (e.g., Version 2 of your app changes a class, which now needs to deal with both Version 1 and Version 2 structures). Also bear in mind that, going this route, you lose a lot of database capabilities (e.g., querying on something in the object).

    You are also welcome to experiment with object databases, or CouchDb, or storing your persistable data structure to a file, if SQLite is not a requirement.

    What most certainly will not work reliably is to pour the Parcelable into a Parcel and try storing the Parcel. A Parcel is meant for IPC use only and is not designed to be persisted. This is one of the reasons why Parcelable is faster than Serializable.

    If you need to persist data, use Serializable. Parcelable is meant for IPC use. It is a binary format and not recommended for persistence.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.