Java tutorial
//package com.java2s; import android.content.Context; import android.telephony.TelephonyManager; import java.lang.reflect.Method; public class Main { public static void setDataEnabled(Context context, boolean enabled) { try { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); Method setMobileDataEnabledMethod = tm.getClass().getDeclaredMethod("setDataEnabled", boolean.class); if (null != setMobileDataEnabledMethod) { setMobileDataEnabledMethod.invoke(tm, enabled); } } catch (Exception e) { e.printStackTrace(); } } }