Format value in Bundle to String - Android android.os

Android examples for android.os:Bundle

Description

Format value in Bundle to String

Demo Code

import android.os.Bundle;

public class Main {

  public static String toString(Bundle b) {
    if (b == null) {
      return "";
    }/*from   w  ww . ja  v a2 s  .c o  m*/

    StringBuffer buff = new StringBuffer();
    for (String key : b.keySet()) {
      final Object value = b.get(key);
      final String s = String.format("%s %s (%s)\n", key, value.toString(), value.getClass().getName());
      buff.append(s);
    }
    return buff.toString();
  }

}

Related Tutorials