Search code examples
androidbundle

Android: Bundle.toString() and then create a Bundle from String


I'm trying to do the following:

// I have a Bundle and convert it to string
Bundle _bundle;
// Meanwhile I put intergers, booleans etc in _bundle
String _strBundle = _bundle.toString();

Later in my code I need to create a Bundle from _strBundle. How do I do that? So far I couldn't find any information on this. Of course I don't wish to parse _strBundle myself and hope that the fremawork already provides a String2Bundle sort of a functionality.


Solution

  • As far as i know there is no way for the framework to know what is stored in your string. The same pattern could have possible interpretations (string, boolean, integer) and so i don't think that that actually even makes sense.

    In fact i can't imagine why you would need to do it. You already have the bundle in the first place. I suggest you keep the original bundle and use it when you need it or make the parse of the string and create the bundle yourself (which won't be an easy task if you want to cover all the possibilities).