add value to Bundle If Not Empty - Android android.os

Android examples for android.os:Bundle

Description

add value to Bundle If Not Empty

Demo Code

import android.os.Bundle;
import android.text.TextUtils;
import java.io.Serializable;

public class Main{

    public static void addIfNotEmpty(Bundle b, Bundle extra) {
        if (extra != null) {
            b.putAll(extra);/*from   ww w  .j  av  a  2 s  . c o  m*/
        }
    }
    public static void addIfNotEmpty(Bundle b, String key, String value) {
        if (value != null && "".equals(value) == false) {
            b.putString(key, value);
        }
    }

}

Related Tutorials