Retrieves java.util.ArrayList of strings from bundle if present. - Android Android OS

Android examples for Android OS:Bundle Get

Description

Retrieves java.util.ArrayList of strings from bundle if present.

Demo Code


//package com.book2s;
import android.os.Bundle;
import java.util.ArrayList;

public class Main {
    /**/*  www  .  j a  v a 2  s. c  o m*/
     * Retrieves {@link java.util.ArrayList} of strings from bundle if present.
     *
     * @param bundle to get from
     * @param key    to search by
     * @return value or empty {@link java.util.ArrayList} if nothing found
     */
    public static ArrayList<String> getArrayList(Bundle bundle, String key) {
        if (bundle != null && bundle.containsKey(key)) {
            return bundle.getStringArrayList(key);
        } else {
            return new ArrayList<String>();
        }
    }
}

Related Tutorials