Java tutorial
//package com.java2s; import android.content.Context; import android.os.Build; import android.provider.Settings; public class Main { private static boolean isMobileDataEnabledFromSettings(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // The row has been moved to 'global' table in API level 17 return Settings.Global.getInt(context.getContentResolver(), "mobile_data", 0) != 0; } try { // It was in 'secure' table before return Settings.Secure.getInt(context.getContentResolver(), "mobile_data") != 0; } catch (Settings.SettingNotFoundException e) { // It was in 'system' table originally, but I don't remember when that was the case. // So, probably, you won't need all these try/catches. // But, hey, it is better to be safe than sorry :) return Settings.System.getInt(context.getContentResolver(), "mobile_data", 0) != 0; } } }