开发者

Android: what is the difference between Bundle Vs java.util collections like HashMap

开发者 https://www.devze.com 2023-03-10 21:52 出处:网络
What 开发者_Go百科is the difference between Bundle Vs java.util collections like HashMap?One difference I can see easily is that a Bundle allows you to put int, boolean, etc., into it while a HashMap

What 开发者_Go百科is the difference between Bundle Vs java.util collections like HashMap?


One difference I can see easily is that a Bundle allows you to put int, boolean, etc., into it while a HashMap seems to require you to convert them to/from objects.

A more important difference is that with a Bundle, every object it contains is parcelable. This allows Bundles to be used as service parameters and to be attached to intents / passed into activities.


A Bundle in Android is a tool the apps use to handle resources. It has built in structure that lets the OS search bundles hierarchically to find a specific resource.

Yes, it is essentially a hash map, but it designed to be a specialized Android component, and not a general purpose data structure.

0

精彩评论

暂无评论...
验证码 换一张
取 消