Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

What is Serializable and Parcelable?

  1. Jul 18, 2016 #1
    Hi everyone, i am an Android developer and want to know your views on Serializable and Parcelable. Which is best approach in Android that will be helpful for me ?
     
  2. jcsd
  3. Jul 18, 2016 #2

    QuantumQuest

    User Avatar
    Gold Member

    Serializable is a marker interface, that you implement on a class and its children. The downside of this approach is that it's slow and creates a lot of temporary objects.

    Parcelable is a more specialized interface, which is significantly faster than Serializable. The downside is that you have to write some - enough in many cases, boilerplate code.

    Everything has its cost. If you can afford the time , then it's better to use Parcelable. On the other hand, in most cases the slowness of Serializable - that is due to reflection that is used, won't be particularly noticeable, so you can write significantly less code and be OK. In general, you have to judge yourself on a per case basis, if it worths the extra time or not.

    I strongly recommend to look up Android documentation, in order to have a complete view about the two choices.
     
    Last edited: Jul 18, 2016
  4. Jul 18, 2016 #3

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Hello Ashish, :welcome:

    +1 for QQ. But I wonder why -- as an android aficionado -- you didn't simply google 'serializable vs parcelable' and ended up with D Phil ?
     
  5. Jul 19, 2016 #4
    Thank you everyone for valuable suggestion.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: What is Serializable and Parcelable?
  1. What is AI? (Replies: 6)

  2. What code is this? (Replies: 6)

  3. What is a DST? (Replies: 1)

Loading...