get String from Bundle Or Throw Exception - Android Android OS

Android examples for Android OS:Bundle Get

Description

get String from Bundle Or Throw Exception

Demo Code


import android.os.Bundle;
import android.os.Parcelable;

public class Main{
    public static String getStringOrThrow(Bundle b, String key)
            throws SQLiteServerProtocolException {
        ensureContainsKey(b, key);//from   ww  w.  java  2  s.  co  m
        return b.getString(key);
    }
    private static void ensureContainsKey(Bundle b, String key)
            throws SQLiteServerProtocolException {
        if (!b.containsKey(key)) {
            throw new SQLiteServerProtocolException(
                    "Missing required key: " + key);
        }
    }
}

Related Tutorials