+ // Close the domains database.
+ domainsCursor.close();
+ domainsDatabaseHelper.close();
+
+
+ // Prepare the preferences table SQL creation string.
+ String CREATE_PREFERENCES_TABLE = "CREATE TABLE " + PREFERENCES_TABLE + " (" +
+ _ID + " INTEGER PRIMARY KEY, " +
+ JAVASCRIPT + " BOOLEAN, " +
+ COOKIES + " BOOLEAN, " +
+ DOM_STORAGE + " BOOLEAN, " +
+ SAVE_FORM_DATA + " BOOLEAN, " +
+ USER_AGENT + " TEXT, " +
+ CUSTOM_USER_AGENT + " TEXT, " +
+ INCOGNITO_MODE + " BOOLEAN, " +
+ ALLOW_SCREENSHOTS + " BOOLEAN, " +
+ EASYLIST + " BOOLEAN, " +
+ EASYPRIVACY + " BOOLEAN, " +
+ FANBOYS_ANNOYANCE_LIST + " BOOLEAN, " +
+ FANBOYS_SOCIAL_BLOCKING_LIST + " BOOLEAN, " +
+ ULTRALIST + " BOOLEAN, " +
+ ULTRAPRIVACY + " BOOLEAN, " +
+ BLOCK_ALL_THIRD_PARTY_REQUESTS + " BOOLEAN, " +
+ GOOGLE_ANALYTICS + " BOOLEAN, " +
+ FACEBOOK_CLICK_IDS + " BOOLEAN, " +
+ TWITTER_AMP_REDIRECTS + " BOOLEAN, " +
+ SEARCH + " TEXT, " +
+ SEARCH_CUSTOM_URL + " TEXT, " +
+ PROXY + " TEXT, " +
+ PROXY_CUSTOM_URL + " TEXT, " +
+ FULL_SCREEN_BROWSING_MODE + " BOOLEAN, " +
+ HIDE_APP_BAR + " BOOLEAN, " +
+ CLEAR_EVERYTHING + " BOOLEAN, " +
+ CLEAR_COOKIES + " BOOLEAN, " +
+ CLEAR_DOM_STORAGE + " BOOLEAN, " +
+ CLEAR_FORM_DATA + " BOOLEAN, " +
+ CLEAR_LOGCAT + " BOOLEAN, " +
+ CLEAR_CACHE + " BOOLEAN, " +
+ HOMEPAGE + " TEXT, " +
+ FONT_SIZE + " TEXT, " +
+ OPEN_INTENTS_IN_NEW_TAB + " BOOLEAN, " +
+ SWIPE_TO_REFRESH + " BOOLEAN, " +
+ DOWNLOAD_WITH_EXTERNAL_APP + " BOOLEAN, " +
+ SCROLL_APP_BAR + " BOOLEAN, " +
+ DISPLAY_ADDITIONAL_APP_BAR_ICONS + " BOOLEAN, " +
+ APP_THEME + " TEXT, " +
+ WEBVIEW_THEME + " TEXT, " +
+ WIDE_VIEWPORT + " BOOLEAN, " +
+ DISPLAY_WEBPAGE_IMAGES + " BOOLEAN)";
+
+ // Create the temporary export database preferences table.
+ temporaryExportDatabase.execSQL(CREATE_PREFERENCES_TABLE);
+
+ // Get a handle for the shared preference.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+
+ // Create a ContentValues with the preferences information.
+ ContentValues preferencesContentValues = new ContentValues();
+ preferencesContentValues.put(JAVASCRIPT, sharedPreferences.getBoolean(JAVASCRIPT, false));
+ preferencesContentValues.put(COOKIES, sharedPreferences.getBoolean(COOKIES, false));
+ preferencesContentValues.put(DOM_STORAGE, sharedPreferences.getBoolean(DOM_STORAGE, false));
+ preferencesContentValues.put(SAVE_FORM_DATA, sharedPreferences.getBoolean(SAVE_FORM_DATA, false)); // Save form data can be removed once the minimum API >= 26.
+ preferencesContentValues.put(USER_AGENT, sharedPreferences.getString(USER_AGENT, context.getString(R.string.user_agent_default_value)));
+ preferencesContentValues.put(CUSTOM_USER_AGENT, sharedPreferences.getString(CUSTOM_USER_AGENT, context.getString(R.string.custom_user_agent_default_value)));
+ preferencesContentValues.put(INCOGNITO_MODE, sharedPreferences.getBoolean(INCOGNITO_MODE, false));
+ preferencesContentValues.put(ALLOW_SCREENSHOTS, sharedPreferences.getBoolean(ALLOW_SCREENSHOTS, false));
+ preferencesContentValues.put(EASYLIST, sharedPreferences.getBoolean(EASYLIST, true));
+ preferencesContentValues.put(EASYPRIVACY, sharedPreferences.getBoolean(EASYPRIVACY, true));
+ preferencesContentValues.put(FANBOYS_ANNOYANCE_LIST, sharedPreferences.getBoolean(FANBOYS_ANNOYANCE_LIST, true));
+ preferencesContentValues.put(FANBOYS_SOCIAL_BLOCKING_LIST, sharedPreferences.getBoolean(FANBOYS_SOCIAL_BLOCKING_LIST, true));
+ preferencesContentValues.put(ULTRALIST, sharedPreferences.getBoolean(ULTRALIST, true));
+ preferencesContentValues.put(ULTRAPRIVACY, sharedPreferences.getBoolean(ULTRAPRIVACY, true));
+ preferencesContentValues.put(BLOCK_ALL_THIRD_PARTY_REQUESTS, sharedPreferences.getBoolean(BLOCK_ALL_THIRD_PARTY_REQUESTS, false));
+ preferencesContentValues.put(GOOGLE_ANALYTICS, sharedPreferences.getBoolean(GOOGLE_ANALYTICS, true));
+ preferencesContentValues.put(FACEBOOK_CLICK_IDS, sharedPreferences.getBoolean(FACEBOOK_CLICK_IDS, true));
+ preferencesContentValues.put(TWITTER_AMP_REDIRECTS, sharedPreferences.getBoolean(TWITTER_AMP_REDIRECTS, true));
+ preferencesContentValues.put(SEARCH, sharedPreferences.getString(SEARCH, context.getString(R.string.search_default_value)));
+ preferencesContentValues.put(SEARCH_CUSTOM_URL, sharedPreferences.getString(SEARCH_CUSTOM_URL, context.getString(R.string.search_custom_url_default_value)));
+ preferencesContentValues.put(PROXY, sharedPreferences.getString(PROXY, context.getString(R.string.proxy_default_value)));
+ preferencesContentValues.put(PROXY_CUSTOM_URL, sharedPreferences.getString(PROXY_CUSTOM_URL, context.getString(R.string.proxy_custom_url_default_value)));
+ preferencesContentValues.put(FULL_SCREEN_BROWSING_MODE, sharedPreferences.getBoolean(FULL_SCREEN_BROWSING_MODE, false));
+ preferencesContentValues.put(HIDE_APP_BAR, sharedPreferences.getBoolean(HIDE_APP_BAR, true));
+ preferencesContentValues.put(CLEAR_EVERYTHING, sharedPreferences.getBoolean(CLEAR_EVERYTHING, true));
+ preferencesContentValues.put(CLEAR_COOKIES, sharedPreferences.getBoolean(CLEAR_COOKIES, true));
+ preferencesContentValues.put(CLEAR_DOM_STORAGE, sharedPreferences.getBoolean(CLEAR_DOM_STORAGE, true));
+ preferencesContentValues.put(CLEAR_FORM_DATA, sharedPreferences.getBoolean(CLEAR_FORM_DATA, true)); // Clear form data can be removed once the minimum API >= 26.
+ preferencesContentValues.put(CLEAR_LOGCAT, sharedPreferences.getBoolean(CLEAR_LOGCAT, true));
+ preferencesContentValues.put(CLEAR_CACHE, sharedPreferences.getBoolean(CLEAR_CACHE, true));
+ preferencesContentValues.put(HOMEPAGE, sharedPreferences.getString(HOMEPAGE, context.getString(R.string.homepage_default_value)));
+ preferencesContentValues.put(FONT_SIZE, sharedPreferences.getString(FONT_SIZE, context.getString(R.string.font_size_default_value)));
+ preferencesContentValues.put(OPEN_INTENTS_IN_NEW_TAB, sharedPreferences.getBoolean(OPEN_INTENTS_IN_NEW_TAB, true));
+ preferencesContentValues.put(SWIPE_TO_REFRESH, sharedPreferences.getBoolean(SWIPE_TO_REFRESH, true));
+ preferencesContentValues.put(DOWNLOAD_WITH_EXTERNAL_APP, sharedPreferences.getBoolean(DOWNLOAD_WITH_EXTERNAL_APP, false));
+ preferencesContentValues.put(SCROLL_APP_BAR, sharedPreferences.getBoolean(SCROLL_APP_BAR, true));
+ preferencesContentValues.put(DISPLAY_ADDITIONAL_APP_BAR_ICONS, sharedPreferences.getBoolean(DISPLAY_ADDITIONAL_APP_BAR_ICONS, false));
+ preferencesContentValues.put(APP_THEME, sharedPreferences.getString(APP_THEME, context.getString(R.string.app_theme_default_value)));
+ preferencesContentValues.put(WEBVIEW_THEME, sharedPreferences.getString(WEBVIEW_THEME, context.getString(R.string.webview_theme_default_value)));
+ preferencesContentValues.put(WIDE_VIEWPORT, sharedPreferences.getBoolean(WIDE_VIEWPORT, true));
+ preferencesContentValues.put(DISPLAY_WEBPAGE_IMAGES, sharedPreferences.getBoolean(DISPLAY_WEBPAGE_IMAGES, true));
+
+ // Insert the preferences into the temporary export database.
+ temporaryExportDatabase.insert(PREFERENCES_TABLE, null, preferencesContentValues);
+
+ // Close the temporary export database.
+ temporaryExportDatabase.close();
+
+
+ // Create the temporary export file input stream.
+ FileInputStream temporaryExportFileInputStream = new FileInputStream(temporaryExportFile);
+
+ // Create a byte array.
+ byte[] transferByteArray = new byte[1024];
+
+ // Create an integer to track the number of bytes read.
+ int bytesRead;
+
+ // Copy the temporary export file to the export file output stream.
+ while ((bytesRead = temporaryExportFileInputStream.read(transferByteArray)) > 0) {
+ exportFileOutputStream.write(transferByteArray, 0, bytesRead);