I am writing a little app that only I will use and I want to pragmatically enable / disable my mobile data on a rooted android 4.5 device (I am running a custom Android L fo
Use this
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
Method methodSet = tm.class.getDeclaredMethod( "setDataEnabled", boolean.class);
methodSet.invoke(tm, true);
Edit:
This requires permission MODIFY_PHONE_STATE, this is System or signature level permission.
Ideally you could create a runnable jar file with this code and execute it using
export CLASSPATH=
exec app_process your.package.name.classname "$@"
from su shell.