diff --git a/java/src/com/android/inputmethod/compat/DownloadManagerCompatUtils.java b/java/src/com/android/inputmethod/compat/DownloadManagerCompatUtils.java
deleted file mode 100644
index 6209b60..0000000
--- a/java/src/com/android/inputmethod/compat/DownloadManagerCompatUtils.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.compat;
-
-import android.app.DownloadManager;
-
-import java.lang.reflect.Method;
-
-public final class DownloadManagerCompatUtils {
-    // DownloadManager.Request#setAllowedOverMetered() has been introduced
-    // in API level 16 (Build.VERSION_CODES.JELLY_BEAN).
-    private static final Method METHOD_setAllowedOverMetered = CompatUtils.getMethod(
-            DownloadManager.Request.class, "setAllowedOverMetered", boolean.class);
-
-    public static DownloadManager.Request setAllowedOverMetered(
-            final DownloadManager.Request request, final boolean allowOverMetered) {
-        return (DownloadManager.Request)CompatUtils.invoke(request,
-                request /* default return value */, METHOD_setAllowedOverMetered, allowOverMetered);
-    }
-
-    public static final boolean hasSetAllowedOverMetered() {
-        return null != METHOD_setAllowedOverMetered;
-    }
-}
diff --git a/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java b/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java
index ee5106b..6feef9e 100644
--- a/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java
+++ b/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java
@@ -25,7 +25,6 @@
 import android.text.TextUtils;
 import android.util.Log;
 
-import com.android.inputmethod.compat.DownloadManagerCompatUtils;
 import com.android.inputmethod.latin.BinaryDictionaryFileDumper;
 import com.android.inputmethod.latin.R;
 import com.android.inputmethod.latin.common.LocaleUtils;
@@ -86,7 +85,7 @@
          * Execute this action NOW.
          * @param context the context to get system services, resources, databases
          */
-        public void execute(final Context context);
+        void execute(final Context context);
     }
 
     /**
@@ -98,13 +97,10 @@
         private final String mClientId;
         // The data to download. May not be null.
         final WordListMetadata mWordList;
-        final boolean mForceStartNow;
-        public StartDownloadAction(final String clientId,
-                final WordListMetadata wordList, final boolean forceStartNow) {
+        public StartDownloadAction(final String clientId, final WordListMetadata wordList) {
             DebugLogUtils.l("New download action for client ", clientId, " : ", wordList);
             mClientId = clientId;
             mWordList = wordList;
-            mForceStartNow = forceStartNow;
         }
 
         @Override
@@ -143,28 +139,7 @@
             final Request request = new Request(uri);
 
             final Resources res = context.getResources();
-            if (!mForceStartNow) {
-                if (DownloadManagerCompatUtils.hasSetAllowedOverMetered()) {
-                    final boolean allowOverMetered;
-                    switch (UpdateHandler.getDownloadOverMeteredSetting(context)) {
-                    case UpdateHandler.DOWNLOAD_OVER_METERED_DISALLOWED:
-                        // User said no: don't allow.
-                        allowOverMetered = false;
-                        break;
-                    case UpdateHandler.DOWNLOAD_OVER_METERED_ALLOWED:
-                        // User said yes: allow.
-                        allowOverMetered = true;
-                        break;
-                    default: // UpdateHandler.DOWNLOAD_OVER_METERED_SETTING_UNKNOWN
-                        // Don't know: use the default value from configuration.
-                        allowOverMetered = res.getBoolean(R.bool.allow_over_metered);
-                    }
-                    DownloadManagerCompatUtils.setAllowedOverMetered(request, allowOverMetered);
-                } else {
-                    request.setAllowedNetworkTypes(Request.NETWORK_WIFI);
-                }
-                request.setAllowedOverRoaming(res.getBoolean(R.bool.allow_over_roaming));
-            } // if mForceStartNow, then allow all network types and roaming, which is the default.
+            request.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE);
             request.setTitle(mWordList.mDescription);
             request.setNotificationVisibility(
                     res.getBoolean(R.bool.display_notification_for_auto_update)
diff --git a/java/src/com/android/inputmethod/dictionarypack/CommonPreferences.java b/java/src/com/android/inputmethod/dictionarypack/CommonPreferences.java
index 3cd822a..3d0e29e 100644
--- a/java/src/com/android/inputmethod/dictionarypack/CommonPreferences.java
+++ b/java/src/com/android/inputmethod/dictionarypack/CommonPreferences.java
@@ -22,8 +22,6 @@
 public final class CommonPreferences {
     private static final String COMMON_PREFERENCES_NAME = "LatinImeDictPrefs";
 
-    public static final String PREF_FORCE_DOWNLOAD_DICT = "pref_key_force_download_dict";
-
     public static SharedPreferences getCommonPreferences(final Context context) {
         return context.getSharedPreferences(COMMON_PREFERENCES_NAME, 0);
     }
@@ -39,14 +37,4 @@
         editor.putBoolean(id, false);
         editor.apply();
     }
-
-    public static boolean isForceDownloadDict(Context context) {
-        return getCommonPreferences(context).getBoolean(PREF_FORCE_DOWNLOAD_DICT, false);
-    }
-
-    public static void setForceDownloadDict(Context context, boolean forceDownload) {
-        SharedPreferences.Editor editor = getCommonPreferences(context).edit();
-        editor.putBoolean(PREF_FORCE_DOWNLOAD_DICT, forceDownload);
-        editor.apply();
-    }
 }
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
index bbdf2a3..fe988ac 100644
--- a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
+++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
@@ -192,27 +192,22 @@
     }
 
     static void dispatchBroadcast(final Context context, final Intent intent) {
-        if (DATE_CHANGED_INTENT_ACTION.equals(intent.getAction())) {
-            // Do not force download dictionaries on date change updates.
-            CommonPreferences.setForceDownloadDict(context, false);
+        final String action = intent.getAction();
+        if (DATE_CHANGED_INTENT_ACTION.equals(action)) {
             // This happens when the date of the device changes. This normally happens
             // at midnight local time, but it may happen if the user changes the date
             // by hand or something similar happens.
             checkTimeAndMaybeSetupUpdateAlarm(context);
-        } else if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(intent.getAction())) {
+        } else if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(action)) {
             // Intent to trigger an update now.
-            UpdateHandler.tryUpdate(context, CommonPreferences.isForceDownloadDict(context));
-        } else if (DictionaryPackConstants.INIT_AND_UPDATE_NOW_INTENT_ACTION.equals(
-                intent.getAction())) {
-            // Enable force download of dictionaries irrespective of wifi or metered connection.
-            CommonPreferences.setForceDownloadDict(context, true);
-
+            UpdateHandler.tryUpdate(context);
+        } else if (DictionaryPackConstants.INIT_AND_UPDATE_NOW_INTENT_ACTION.equals(action)) {
             // Initialize the client Db.
             final String mClientId = context.getString(R.string.dictionary_pack_client_id);
             BinaryDictionaryFileDumper.initializeClientRecordHelper(context, mClientId);
 
             // Updates the metadata and the download the dictionaries.
-            UpdateHandler.tryUpdate(context, true);
+            UpdateHandler.tryUpdate(context);
         } else {
             UpdateHandler.downloadFinished(context, intent);
         }
@@ -263,7 +258,7 @@
      */
     public static void updateNowIfNotUpdatedInAVeryLongTime(final Context context) {
         if (!isLastUpdateAtLeastThisOld(context, VERY_LONG_TIME_MILLIS)) return;
-        UpdateHandler.tryUpdate(context, CommonPreferences.isForceDownloadDict(context));
+        UpdateHandler.tryUpdate(context);
     }
 
     /**
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java b/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java
index 88ea4e6..35b46a9 100644
--- a/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java
+++ b/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java
@@ -384,7 +384,7 @@
                 // We call tryUpdate(), which returns whether we could successfully start an update.
                 // If we couldn't, we'll never receive the end callback, so we stop the loading
                 // animation and return to the previous screen.
-                if (!UpdateHandler.tryUpdate(activity, true)) {
+                if (!UpdateHandler.tryUpdate(activity)) {
                     stopLoadingAnimation();
                 }
             }
diff --git a/java/src/com/android/inputmethod/dictionarypack/MetadataDbHelper.java b/java/src/com/android/inputmethod/dictionarypack/MetadataDbHelper.java
index 003929d..78d13eb 100644
--- a/java/src/com/android/inputmethod/dictionarypack/MetadataDbHelper.java
+++ b/java/src/com/android/inputmethod/dictionarypack/MetadataDbHelper.java
@@ -266,8 +266,6 @@
      */
     @Override
     public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
-        // Allow automatic download of dictionaries on upgrading the database.
-        CommonPreferences.setForceDownloadDict(mContext, true);
         if (METADATA_DATABASE_INITIAL_VERSION == oldVersion
                 && METADATA_DATABASE_VERSION_WITH_CLIENTID <= newVersion
                 && CURRENT_METADATA_DATABASE_VERSION >= newVersion) {
diff --git a/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java b/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java
index f30f248..d1e3c91 100644
--- a/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java
+++ b/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java
@@ -36,7 +36,6 @@
 import android.util.Log;
 
 import com.android.inputmethod.compat.ConnectivityManagerCompatUtils;
-import com.android.inputmethod.compat.DownloadManagerCompatUtils;
 import com.android.inputmethod.compat.NotificationCompatUtils;
 import com.android.inputmethod.latin.R;
 import com.android.inputmethod.latin.common.LocaleUtils;
@@ -106,9 +105,9 @@
      * This is chiefly used by the dictionary manager UI.
      */
     public interface UpdateEventListener {
-        public void downloadedMetadata(boolean succeeded);
-        public void wordListDownloadFinished(String wordListId, boolean succeeded);
-        public void updateCycleCompleted();
+        void downloadedMetadata(boolean succeeded);
+        void wordListDownloadFinished(String wordListId, boolean succeeded);
+        void updateCycleCompleted();
     }
 
     /**
@@ -179,10 +178,9 @@
     /**
      * Download latest metadata from the server through DownloadManager for all known clients
      * @param context The context for retrieving resources
-     * @param updateNow Whether we should update NOW, or respect bandwidth policies
      * @return true if an update successfully started, false otherwise.
      */
-    public static boolean tryUpdate(final Context context, final boolean updateNow) {
+    public static boolean tryUpdate(final Context context) {
         // TODO: loop through all clients instead of only doing the default one.
         final TreeSet<String> uris = new TreeSet<>();
         final Cursor cursor = MetadataDbHelper.queryClientIds(context);
@@ -208,7 +206,7 @@
                 // it should have been rejected at the time of client registration; if there
                 // is a bug and it happens anyway, doing nothing is the right thing to do.
                 // For more information, {@see DictionaryProvider#insert(Uri, ContentValues)}.
-                updateClientsWithMetadataUri(context, updateNow, metadataUri);
+                updateClientsWithMetadataUri(context, metadataUri);
                 started = true;
             }
         }
@@ -219,11 +217,10 @@
      * Download latest metadata from the server through DownloadManager for all relevant clients
      *
      * @param context The context for retrieving resources
-     * @param updateNow Whether we should update NOW, or respect bandwidth policies
      * @param metadataUri The client to update
      */
-    private static void updateClientsWithMetadataUri(final Context context,
-            final boolean updateNow, final String metadataUri) {
+    private static void updateClientsWithMetadataUri(
+            final Context context, final String metadataUri) {
         PrivateLog.log("Update for metadata URI " + DebugLogUtils.s(metadataUri));
         // Adding a disambiguator to circumvent a bug in older versions of DownloadManager.
         // DownloadManager also stupidly cuts the extension to replace with its own that it
@@ -234,19 +231,7 @@
         DebugLogUtils.l("Request =", metadataRequest);
 
         final Resources res = context.getResources();
-        // By default, download over roaming is allowed and all network types are allowed too.
-        if (!updateNow) {
-            final boolean allowedOverMetered = res.getBoolean(R.bool.allow_over_metered);
-            // If we don't have to update NOW, then only do it over non-metered connections.
-            if (DownloadManagerCompatUtils.hasSetAllowedOverMetered()) {
-                DownloadManagerCompatUtils.setAllowedOverMetered(metadataRequest,
-                        allowedOverMetered);
-            } else if (!allowedOverMetered) {
-                metadataRequest.setAllowedNetworkTypes(Request.NETWORK_WIFI);
-            }
-            metadataRequest.setAllowedOverRoaming(res.getBoolean(R.bool.allow_over_roaming));
-        }
-
+        metadataRequest.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE);
         metadataRequest.setTitle(res.getString(R.string.download_description));
         // Do not show the notification when downloading the metadata.
         metadataRequest.setNotificationVisibility(Request.VISIBILITY_HIDDEN);
@@ -448,8 +433,6 @@
         // download, so we are pretty sure it's alive. It's theoretically possible that it's
         // disabled right inbetween the firing of the intent and the control reaching here.
 
-        boolean dictionaryDownloaded = false;
-
         for (final DownloadRecord record : recordList) {
             // downloadSuccessful is not final because we may still have exceptions from now on
             boolean downloadSuccessful = false;
@@ -464,15 +447,9 @@
                     final SQLiteDatabase db = MetadataDbHelper.getDb(context, record.mClientId);
                     publishUpdateWordListCompleted(context, downloadSuccessful, fileId,
                             db, record.mAttributes, record.mClientId);
-                    dictionaryDownloaded = true;
                 }
             }
         }
-
-        if (dictionaryDownloaded) {
-            // Disable the force download after downloading the dictionaries.
-            CommonPreferences.setForceDownloadDict(context, false);
-        }
         // Now that we're done using it, we can remove this download from DLManager
         manager.remove(fileId);
     }
@@ -829,8 +806,7 @@
                     actions.add(new ActionBatch.MakeAvailableAction(clientId, newInfo));
                     if (status == MetadataDbHelper.STATUS_INSTALLED
                             || status == MetadataDbHelper.STATUS_DISABLED) {
-                        actions.add(new ActionBatch.StartDownloadAction(
-                                clientId, newInfo, CommonPreferences.isForceDownloadDict(context)));
+                        actions.add(new ActionBatch.StartDownloadAction(clientId, newInfo));
                     } else {
                         // Pass true to ForgetAction: this is indeed an update to a non-installed
                         // word list, so activate status == AVAILABLE check
@@ -984,9 +960,7 @@
         // auto-installed once to get auto-installed again, and that's what we want.
         final ActionBatch actions = new ActionBatch();
         actions.add(new ActionBatch.StartDownloadAction(
-                clientId,
-                WordListMetadata.createFromContentValues(installCandidate),
-                CommonPreferences.isForceDownloadDict(context)));
+                clientId, WordListMetadata.createFromContentValues(installCandidate)));
         final String localeString = installCandidate.getAsString(MetadataDbHelper.LOCALE_COLUMN);
         // We are in a content provider: we can't do any UI at all. We have to defer the displaying
         // itself to the service. Also, we only display this when the user does not have a
@@ -1032,9 +1006,7 @@
                 || MetadataDbHelper.STATUS_DELETING == status) {
             actions.add(new ActionBatch.EnableAction(clientId, wordListMetaData));
         } else if (MetadataDbHelper.STATUS_AVAILABLE == status) {
-            boolean forceDownloadDict = CommonPreferences.isForceDownloadDict(context);
-            actions.add(new ActionBatch.StartDownloadAction(clientId, wordListMetaData,
-                    forceDownloadDict || allowDownloadOnMeteredData));
+            actions.add(new ActionBatch.StartDownloadAction(clientId, wordListMetaData));
         } else {
             Log.e(TAG, "Unexpected state of the word list for markAsUsed : " + status);
         }
@@ -1149,8 +1121,7 @@
             }
 
             final ActionBatch actions = new ActionBatch();
-            actions.add(new ActionBatch.StartDownloadAction(
-                    clientId, wordListMetaData, CommonPreferences.isForceDownloadDict(context)));
+            actions.add(new ActionBatch.StartDownloadAction(clientId, wordListMetaData));
             actions.execute(context, new LogProblemReporter(TAG));
         } else {
             if (DEBUG) {
