Sorting a key-value pair of a package in android

I have a list of key-value pairs in the bundle

params.keySet ()

to be sorted alphabetically in the key column.

I tried a long way of extracting key-value pairs and sorting them using

Collections.sort (list)

and return it back to the new package.

But when I call params.keySet (). They are not sorted again. Any ideas. Is this their easy way?

+3
source share
2 answers

BundleIt is supported by a symbol HashMap, so it does not guarantee the order of the keys. You will have to rethink the logic in your application in order to break the dependency on the key order in the Bundle.

+2
source

public Set<String> keySet () Set guarantees the absence of duplicates, but not the order.

java.util.SortedMap Bundle.

0

All Articles