Android - How to check if Developer option is enabled

try this:

int adb = Settings.Secure.getInt(this.getContentResolver(),
                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0);

You should use getInt or another in Settings.Global with DEVELOPMENT_SETTINGS_ENABLED

Edit : Below API 17, it is the same but with Settings.Secure


Here's a method that returns true if developer mode is enabled for all devices at Android 4.1 or above (API 16), returns false if developer mode is not enabled on such devices, and returns false on all earlier Android devices down to 1.0.

        @android.annotation.TargetApi(17) public boolean isDevMode() {
            if(Integer.valueOf(android.os.Build.VERSION.SDK) == 16) {
                return android.provider.Settings.Secure.getInt(getApplicationContext().getContentResolver(),
                        android.provider.Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED , 0) != 0;
            } else if (Integer.valueOf(android.os.Build.VERSION.SDK) >= 17) {
                return android.provider.Settings.Secure.getInt(getApplicationContext().getContentResolver(),
                        android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0) != 0;
            } else return false;
        }

Kotlin solution:

@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
fun isDevMode(context: Context): Boolean {
    return when {
        Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN -> {
            Settings.Secure.getInt(context.contentResolver,
                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0
        }
        Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN -> {
            @Suppress("DEPRECATION")
            Settings.Secure.getInt(context.contentResolver,
                Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0
        }
        else -> false
    }
}