Code example for ConnectivityManager

Methods: getMobileDataEnabled

0
     * @return true if enabled. 
     */ 
    private static boolean getDataState(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
        return cm.getMobileDataEnabled();
    } 
 
    /** 
     * Toggles the state of data. 
     * 
     */ 
    @Override 
    public void toggleState(Context context) {
        boolean enabled = getDataState(context);
 
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (enabled) {
            cm.setMobileDataEnabled(false);
        } else {