I'm using the following code to read a map of type HashMap<String, String
> from a Parcel:
in.readHashMap(HashMap.class.getClassLoader());
This seems to work just fine, but I get a warning:
Type safety: The expression of type HashMap needs unchecked conversion to conform to Map<String,String>
Is there a "right" way to do this, use a different class loader? Or should I just go with @SuppressWarnings("unchecked"
)?
The Android developer documentation for Parcel.readHashMap()
says:
Please use
readBundle(ClassLoader)
instead (whose data must have been written withwriteBundle(Bundle)
.
So maybe you should be using readBundle()
and writeBundle()
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With