The Bundle and ContentValues classes seem to have pretty similar functionality.
Is there an efficient way of converting from one to another (and vice-versa) without having to loop through the classes, calling get and put subsequently on each element?
I’ve scanned the Android source code and both Classes use a
Mapto hold the underlying data. Specifically,Bundleuses aMapand ContentValues uses aHashMap.However,
Bundlepermits any parcelable objects to be loaded, whileContentValues‘ implementation accepts the primitive type classes (Integer, String, Doubleetc.) and byte arrays.So it looks like in principle,
ContentValuesis a special case ofBundle, so converting fromContentValuestoBundlemight have been possible if the internals were accessible, but the reverse is problematic, since aBundlecan hold objects not strictly compatible withContentValues.Any comments on this are welcome.