Search code examples
androidjsonbundle

What are differences between Bundle and JSONObject in Android development?


We can use JSONObject or JSONArray data structures for to store key-value pairs in the apps.

Also we can use Bundle for to store key-value pairs in the apps.

So, what are differences between their?

Is there any advantage/disadvantage of using any one instead of the other one?


Solution

  • In android, Bundle is associated with fragment/activity/Service/BroadcastReceiver. It is used to send data from one activity/fragment to another. we can send data through JSONObject too but we need medium to transfer data either common filesystem or local db or bundle. Bundle is a key value pair data structure as well as a medium. JSONObject is mostly used in web apis and to serialize Objects.