Turn ON/OFF the Auto Sync Code in Java for Android
This Code works from Android API Level 5 -
private void turnAutoSyncOff(){
ContentResolver.setMasterSyncAutomatically(false);
}
private void turnAutoSyncOn(){
ContentResolver.setMasterSyncAutomatically(true);
}
private boolean isAutoSync() {
return ContentResolver.getMasterSyncAutomatically();
}
private void turnAutoSyncOff(){
ContentResolver.setMasterSyncAutomatically(false);
}
private void turnAutoSyncOn(){
ContentResolver.setMasterSyncAutomatically(true);
}
private boolean isAutoSync() {
return ContentResolver.getMasterSyncAutomatically();
}
permission android.permission.WRITE_SYNC_SETTINGS
permission android.permission.READ_SYNC_SETTINGS
in your Manifest.xml