How to Iterate through all Bundle objects

Could you save everything as String using the toString() method? Don’t know if primitive types are mapped to their Object equivalents (e.g. int to class Integer), but if they are, then you might be able to do something like this, instead of laboriously checking each possible class.

 for (String key : bundle.keySet()) {
        saveKeyValueInPrefs(key, bundle.get(key).toString()); //To Implement
 }

Not sure if this would work for your needs, but I’m trying to do something similar to convert a bundle into a JSON string right now.

Leave a Comment