2 * Copyright © 2017-2018 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
6 * Privacy Browser is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Browser is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacybrowser.helpers;
22 import android.content.ContentValues;
23 import android.content.Context;
24 import android.content.SharedPreferences;
25 import android.database.Cursor;
26 import android.database.sqlite.SQLiteDatabase;
27 import android.database.sqlite.SQLiteOpenHelper;
28 import android.preference.PreferenceManager;
30 public class DomainsDatabaseHelper extends SQLiteOpenHelper {
31 private static final int SCHEMA_VERSION = 5;
32 private static final String DOMAINS_DATABASE = "domains.db";
33 private static final String DOMAINS_TABLE = "domains";
35 public static final String _ID = "_id";
36 public static final String DOMAIN_NAME = "domainname";
37 public static final String ENABLE_JAVASCRIPT = "enablejavascript";
38 public static final String ENABLE_FIRST_PARTY_COOKIES = "enablefirstpartycookies";
39 public static final String ENABLE_THIRD_PARTY_COOKIES = "enablethirdpartycookies";
40 public static final String ENABLE_DOM_STORAGE = "enabledomstorage";
41 public static final String ENABLE_FORM_DATA = "enableformdata";
42 public static final String ENABLE_EASYLIST = "enableeasylist";
43 public static final String ENABLE_EASYPRIVACY = "enableeasyprivacy";
44 public static final String ENABLE_FANBOYS_ANNOYANCE_LIST = "enablefanboysannoyancelist";
45 public static final String ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST = "enablefanboyssocialblockinglist";
46 public static final String USER_AGENT = "useragent";
47 public static final String FONT_SIZE = "fontsize";
48 public static final String DISPLAY_IMAGES = "displayimages";
49 public static final String NIGHT_MODE = "nightmode";
50 public static final String PINNED_SSL_CERTIFICATE = "pinnedsslcertificate";
51 public static final String SSL_ISSUED_TO_COMMON_NAME = "sslissuedtocommonname";
52 public static final String SSL_ISSUED_TO_ORGANIZATION = "sslissuedtoorganization";
53 public static final String SSL_ISSUED_TO_ORGANIZATIONAL_UNIT = "sslissuedtoorganizationalunit";
54 public static final String SSL_ISSUED_BY_COMMON_NAME = "sslissuedbycommonname";
55 public static final String SSL_ISSUED_BY_ORGANIZATION = "sslissuedbyorganization";
56 public static final String SSL_ISSUED_BY_ORGANIZATIONAL_UNIT = "sslissuedbyorganizationalunit";
57 public static final String SSL_START_DATE = "sslstartdate";
58 public static final String SSL_END_DATE = "sslenddate";
60 // Display webpage images constants.
61 public static final int DISPLAY_WEBPAGE_IMAGES_SYSTEM_DEFAULT = 0;
62 public static final int DISPLAY_WEBPAGE_IMAGES_ENABLED = 1;
63 public static final int DISPLAY_WEBPAGE_IMAGES_DISABLED = 2;
65 // Night mode constants.
66 public static final int NIGHT_MODE_SYSTEM_DEFAULT = 0;
67 public static final int NIGHT_MODE_ENABLED = 1;
68 public static final int NIGHT_MODE_DISABLED = 2;
70 private Context appContext;
72 // Initialize the database. The lint warnings for the unused parameters are suppressed.
73 public DomainsDatabaseHelper(Context context, @SuppressWarnings("UnusedParameters") String name, SQLiteDatabase.CursorFactory cursorFactory, @SuppressWarnings("UnusedParameters") int version) {
74 super(context, DOMAINS_DATABASE, cursorFactory, SCHEMA_VERSION);
76 // Store a handle for the context.
81 public void onCreate(SQLiteDatabase domainsDatabase) {
82 // Setup the SQL string to create the `domains` table.
83 String CREATE_DOMAINS_TABLE = "CREATE TABLE " + DOMAINS_TABLE + " (" +
84 _ID + " INTEGER PRIMARY KEY, " +
85 DOMAIN_NAME + " TEXT, " +
86 ENABLE_JAVASCRIPT + " BOOLEAN, " +
87 ENABLE_FIRST_PARTY_COOKIES + " BOOLEAN, " +
88 ENABLE_THIRD_PARTY_COOKIES + " BOOLEAN, " +
89 ENABLE_DOM_STORAGE + " BOOLEAN, " +
90 ENABLE_FORM_DATA + " BOOLEAN, " +
91 ENABLE_EASYLIST + " BOOLEAN, " +
92 ENABLE_EASYPRIVACY + " BOOLEAN, " +
93 ENABLE_FANBOYS_ANNOYANCE_LIST + " BOOLEAN, " +
94 ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST + " BOOLEAN, " +
95 USER_AGENT + " TEXT, " +
96 FONT_SIZE + " INTEGER, " +
97 DISPLAY_IMAGES + " INTEGER, " +
98 NIGHT_MODE + " INTEGER, " +
99 PINNED_SSL_CERTIFICATE + " BOOLEAN, " +
100 SSL_ISSUED_TO_COMMON_NAME + " TEXT, " +
101 SSL_ISSUED_TO_ORGANIZATION + " TEXT, " +
102 SSL_ISSUED_TO_ORGANIZATIONAL_UNIT + " TEXT, " +
103 SSL_ISSUED_BY_COMMON_NAME + " TEXT, " +
104 SSL_ISSUED_BY_ORGANIZATION + " TEXT, " +
105 SSL_ISSUED_BY_ORGANIZATIONAL_UNIT + " TEXT, " +
106 SSL_START_DATE + " INTEGER, " +
107 SSL_END_DATE + " INTEGER);";
110 domainsDatabase.execSQL(CREATE_DOMAINS_TABLE);
114 public void onUpgrade(SQLiteDatabase domainsDatabase, int oldVersion, int newVersion) {
115 // Upgrade the database table.
116 switch (oldVersion) {
117 // Upgrade from schema version 1.
119 // Add the display images column.
120 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + DISPLAY_IMAGES + " INTEGER");
122 // Upgrade from schema version 2.
124 // Add the SSL certificate columns.
125 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + PINNED_SSL_CERTIFICATE + " BOOLEAN");
126 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SSL_ISSUED_TO_COMMON_NAME + " TEXT");
127 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SSL_ISSUED_TO_ORGANIZATION + " TEXT");
128 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SSL_ISSUED_TO_ORGANIZATIONAL_UNIT + " TEXT");
129 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SSL_ISSUED_BY_COMMON_NAME + " TEXT");
130 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SSL_ISSUED_BY_ORGANIZATION + " TEXT");
131 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SSL_ISSUED_BY_ORGANIZATIONAL_UNIT + " TEXT");
132 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SSL_START_DATE + " INTEGER");
133 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SSL_END_DATE + " INTEGER");
135 // Upgrade from schema version 3.
137 // Add the `NIGHT_MODE` column.
138 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + NIGHT_MODE + " INTEGER");
140 // Upgrade from schema version 4.
142 // Add the block lists columns.
143 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ENABLE_EASYLIST + " BOOLEAN");
144 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ENABLE_EASYPRIVACY + " BOOLEAN");
145 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ENABLE_FANBOYS_ANNOYANCE_LIST + " BOOLEAN");
146 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST + " BOOLEAN");
148 // Get a handle for the shared preference.
149 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext);
151 // Get the default block list settings.
152 boolean easyListEnabled = sharedPreferences.getBoolean("easylist", true);
153 boolean easyPrivacyEnabled = sharedPreferences.getBoolean("easyprivacy", true);
154 boolean fanboyAnnoyanceListEnabled = sharedPreferences.getBoolean("fanboy_annoyance_list", true);
155 boolean fanboySocialBlockingListEnabled = sharedPreferences.getBoolean("fanboy_social_blocking_list", true);
157 // Set EasyList for existing rows according to the current system-wide default.
158 if (easyListEnabled) {
159 domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_EASYLIST + " = " + 1);
161 domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_EASYLIST + " = " + 0);
164 // Set EasyPrivacy for existing rows according to the current system-wide default.
165 if (easyPrivacyEnabled) {
166 domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_EASYPRIVACY + " = " + 1);
168 domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_EASYPRIVACY + " = " + 0);
171 // Set Fanboy's Annoyance List for existing rows according to the current system-wide default.
172 if (fanboyAnnoyanceListEnabled) {
173 domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_FANBOYS_ANNOYANCE_LIST + " = " + 1);
175 domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_FANBOYS_ANNOYANCE_LIST + " = " + 0);
178 // Set Fanboy's Social Blocking List for existing rows according to the current system-wide default.
179 if (fanboySocialBlockingListEnabled) {
180 domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST + " = " + 1);
182 domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST + " = " + 0);
187 public Cursor getDomainNameCursorOrderedByDomain() {
188 // Get a readable database handle.
189 SQLiteDatabase domainsDatabase = this.getReadableDatabase();
191 // Get everything in `DOMAINS_TABLE` ordered by `DOMAIN_NAME`.
192 final String GET_CURSOR_ORDERED_BY_DOMAIN = "SELECT " + _ID + ", " + DOMAIN_NAME +
193 " FROM " + DOMAINS_TABLE +
194 " ORDER BY " + DOMAIN_NAME + " ASC";
196 // Return the results as a `Cursor`. The second argument is `null` because there are no `selectionArgs`. We can't close the `Cursor` because we need to use it in the parent activity.
197 return domainsDatabase.rawQuery(GET_CURSOR_ORDERED_BY_DOMAIN, null);
200 public Cursor getDomainNameCursorOrderedByDomainExcept(int databaseId) {
201 // Get a readable database handle.
202 SQLiteDatabase domainsDatabase = this.getReadableDatabase();
204 // Prepare the SQL statement to select all rows except that with `databaseId`.
205 final String GET_CURSOR_ORDERED_BY_DOMAIN_EXCEPT = "SELECT " + _ID + ", " + DOMAIN_NAME +
206 " FROM " + DOMAINS_TABLE +
207 " WHERE " + _ID + " IS NOT " + databaseId +
208 " ORDER BY " + DOMAIN_NAME + " ASC";
210 // Return the results as a `Cursor`. The second argument is `null` because there are no `selectionArgs`. We can't close the `Cursor` because we need to use it in the calling activity.
211 return domainsDatabase.rawQuery(GET_CURSOR_ORDERED_BY_DOMAIN_EXCEPT, null);
214 public Cursor getCursorForId(int databaseId) {
215 // Get a readable database handle.
216 SQLiteDatabase domainsDatabase = this.getReadableDatabase();
218 // Prepare the SQL statement to get the `Cursor` for `databaseId`.
219 final String GET_CURSOR_FOR_ID = "SELECT * FROM " + DOMAINS_TABLE +
220 " WHERE " + _ID + " = " + databaseId;
222 // Return the results as a `Cursor`. The second argument is `null` because there are no `selectionArgs`. We can't close the `Cursor` because we need to use it in the calling activity.
223 return domainsDatabase.rawQuery(GET_CURSOR_FOR_ID, null);
226 public Cursor getCursorForDomainName(String domainName) {
227 // Get a readable database handle.
228 SQLiteDatabase domainsDatabase = this.getReadableDatabase();
230 // Prepare the SQL statement to get the `Cursor` for `domainName`.
231 final String GET_CURSOR_FOR_DOMAIN_NAME = "SELECT * FROM " + DOMAINS_TABLE +
232 " WHERE " + DOMAIN_NAME + " = " + "\"" + domainName + "\"";
234 // Return the results as a `Cursor`. The second argument is `null` because there are no `selectionArgs`. We can't close the `Cursor` because we need to us it in the calling activity.
235 return domainsDatabase.rawQuery(GET_CURSOR_FOR_DOMAIN_NAME, null);
238 public int addDomain(String domainName) {
239 // Store the domain data in a `ContentValues`.
240 ContentValues domainContentValues = new ContentValues();
242 // Get a handle for the shared preference.
243 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext);
245 // Get the default settings.
246 boolean javaScriptEnabled = sharedPreferences.getBoolean("javascript_enabled", false);
247 boolean firstPartyCookiesEnabled = sharedPreferences.getBoolean("first_party_cookies_enabled", false);
248 boolean thirdPartyCookiesEnabled = sharedPreferences.getBoolean("third_party_cookies_enabled", false);
249 boolean domStorageEnabled = sharedPreferences.getBoolean("dom_storage_enabled", false);
250 boolean saveFormDataEnabled = sharedPreferences.getBoolean("save_form_data_enabled", false);
251 boolean easyListEnabled = sharedPreferences.getBoolean("easylist", true);
252 boolean easyPrivacyEnabled = sharedPreferences.getBoolean("easyprivacy", true);
253 boolean fanboyAnnoyanceListEnabled = sharedPreferences.getBoolean("fanboy_annoyance_list", true);
254 boolean fanboySocialBlockingListEnabled = sharedPreferences.getBoolean("fanboy_social_blocking_list", true);
256 // Create entries for the database fields. The ID is created automatically. The pinned SSL certificate information is not created unless added by the user.
257 domainContentValues.put(DOMAIN_NAME, domainName);
258 domainContentValues.put(ENABLE_JAVASCRIPT, javaScriptEnabled);
259 domainContentValues.put(ENABLE_FIRST_PARTY_COOKIES, firstPartyCookiesEnabled);
260 domainContentValues.put(ENABLE_THIRD_PARTY_COOKIES, thirdPartyCookiesEnabled);
261 domainContentValues.put(ENABLE_DOM_STORAGE, domStorageEnabled);
262 domainContentValues.put(ENABLE_FORM_DATA, saveFormDataEnabled);
263 domainContentValues.put(ENABLE_EASYLIST, easyListEnabled);
264 domainContentValues.put(ENABLE_EASYPRIVACY, easyPrivacyEnabled);
265 domainContentValues.put(ENABLE_FANBOYS_ANNOYANCE_LIST, fanboyAnnoyanceListEnabled);
266 domainContentValues.put(ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST, fanboySocialBlockingListEnabled);
267 domainContentValues.put(USER_AGENT, "System default user agent");
268 domainContentValues.put(FONT_SIZE, 0);
269 domainContentValues.put(DISPLAY_IMAGES, 0);
270 domainContentValues.put(NIGHT_MODE, 0);
272 // Get a writable database handle.
273 SQLiteDatabase domainsDatabase = this.getWritableDatabase();
275 // Insert a new row and store the resulting database ID. The second argument is `null`, which makes it so that a completely null row cannot be created.
276 int newDomainDatabaseId = (int) domainsDatabase.insert(DOMAINS_TABLE, null, domainContentValues);
278 // Close the database handle.
279 domainsDatabase.close();
281 // Return the new domain database ID.
282 return newDomainDatabaseId;
285 public void updateDomainExceptCertificate(int databaseId, String domainName, boolean javaScriptEnabled, boolean firstPartyCookiesEnabled, boolean thirdPartyCookiesEnabled, boolean domStorageEnabled,
286 boolean formDataEnabled, boolean easyListEnabled, boolean easyPrivacyEnabled, boolean fanboysAnnoyanceEnabled, boolean fanboysSocialBlockingEnabled,
287 String userAgent, int fontSize, int displayImages, int nightMode, boolean pinnedSslCertificate) {
289 // Store the domain data in a `ContentValues`.
290 ContentValues domainContentValues = new ContentValues();
292 // Add entries for each field in the database.
293 domainContentValues.put(DOMAIN_NAME, domainName);
294 domainContentValues.put(ENABLE_JAVASCRIPT, javaScriptEnabled);
295 domainContentValues.put(ENABLE_FIRST_PARTY_COOKIES, firstPartyCookiesEnabled);
296 domainContentValues.put(ENABLE_THIRD_PARTY_COOKIES, thirdPartyCookiesEnabled);
297 domainContentValues.put(ENABLE_DOM_STORAGE, domStorageEnabled);
298 domainContentValues.put(ENABLE_FORM_DATA, formDataEnabled);
299 domainContentValues.put(ENABLE_EASYLIST, easyListEnabled);
300 domainContentValues.put(ENABLE_EASYPRIVACY, easyPrivacyEnabled);
301 domainContentValues.put(ENABLE_FANBOYS_ANNOYANCE_LIST, fanboysAnnoyanceEnabled);
302 domainContentValues.put(ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST, fanboysSocialBlockingEnabled);
303 domainContentValues.put(USER_AGENT, userAgent);
304 domainContentValues.put(FONT_SIZE, fontSize);
305 domainContentValues.put(DISPLAY_IMAGES, displayImages);
306 domainContentValues.put(NIGHT_MODE, nightMode);
307 domainContentValues.put(PINNED_SSL_CERTIFICATE, pinnedSslCertificate);
309 // Get a writable database handle.
310 SQLiteDatabase domainsDatabase = this.getWritableDatabase();
312 // Update the row for `databaseId`. The last argument is `null` because there are no `whereArgs`.
313 domainsDatabase.update(DOMAINS_TABLE, domainContentValues, _ID + " = " + databaseId, null);
315 // Close the database handle.
316 domainsDatabase.close();
319 public void updateDomainWithCertificate(int databaseId, String domainName, boolean javaScriptEnabled, boolean firstPartyCookiesEnabled, boolean thirdPartyCookiesEnabled, boolean domStorageEnabled,
320 boolean formDataEnabled, boolean easyListEnabled, boolean easyPrivacyEnabled, boolean fanboysAnnoyanceEnabled, boolean fanboysSocialBlockingEnabled, String userAgent,
321 int fontSize, int displayImages, int nightMode, boolean pinnedSslCertificate, String sslIssuedToCommonName, String sslIssuedToOrganization,
322 String sslIssuedToOrganizationalUnit, String sslIssuedByCommonName, String sslIssuedByOrganization, String sslIssuedByOrganizationalUnit, long sslStartDate,
325 // Store the domain data in a `ContentValues`.
326 ContentValues domainContentValues = new ContentValues();
328 // Add entries for each field in the database.
329 domainContentValues.put(DOMAIN_NAME, domainName);
330 domainContentValues.put(ENABLE_JAVASCRIPT, javaScriptEnabled);
331 domainContentValues.put(ENABLE_FIRST_PARTY_COOKIES, firstPartyCookiesEnabled);
332 domainContentValues.put(ENABLE_THIRD_PARTY_COOKIES, thirdPartyCookiesEnabled);
333 domainContentValues.put(ENABLE_DOM_STORAGE, domStorageEnabled);
334 domainContentValues.put(ENABLE_FORM_DATA, formDataEnabled);
335 domainContentValues.put(ENABLE_EASYLIST, easyListEnabled);
336 domainContentValues.put(ENABLE_EASYPRIVACY, easyPrivacyEnabled);
337 domainContentValues.put(ENABLE_FANBOYS_ANNOYANCE_LIST, fanboysAnnoyanceEnabled);
338 domainContentValues.put(ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST, fanboysSocialBlockingEnabled);
339 domainContentValues.put(USER_AGENT, userAgent);
340 domainContentValues.put(FONT_SIZE, fontSize);
341 domainContentValues.put(DISPLAY_IMAGES, displayImages);
342 domainContentValues.put(NIGHT_MODE, nightMode);
343 domainContentValues.put(PINNED_SSL_CERTIFICATE, pinnedSslCertificate);
344 domainContentValues.put(SSL_ISSUED_TO_COMMON_NAME, sslIssuedToCommonName);
345 domainContentValues.put(SSL_ISSUED_TO_ORGANIZATION, sslIssuedToOrganization);
346 domainContentValues.put(SSL_ISSUED_TO_ORGANIZATIONAL_UNIT, sslIssuedToOrganizationalUnit);
347 domainContentValues.put(SSL_ISSUED_BY_COMMON_NAME, sslIssuedByCommonName);
348 domainContentValues.put(SSL_ISSUED_BY_ORGANIZATION, sslIssuedByOrganization);
349 domainContentValues.put(SSL_ISSUED_BY_ORGANIZATIONAL_UNIT, sslIssuedByOrganizationalUnit);
350 domainContentValues.put(SSL_START_DATE, sslStartDate);
351 domainContentValues.put(SSL_END_DATE, sslEndDate);
353 // Get a writable database handle.
354 SQLiteDatabase domainsDatabase = this.getWritableDatabase();
356 // Update the row for `databaseId`. The last argument is `null` because there are no `whereArgs`.
357 domainsDatabase.update(DOMAINS_TABLE, domainContentValues, _ID + " = " + databaseId, null);
359 // Close the database handle.
360 domainsDatabase.close();
363 public void updateCertificate(int databaseId, String sslIssuedToCommonName, String sslIssuedToOrganization, String sslIssuedToOrganizationalUnit, String sslIssuedByCommonName,
364 String sslIssuedByOrganization, String sslIssuedByOrganizationalUnit, long sslStartDate, long sslEndDate) {
365 // Store the domain data in a `ContentValues`.
366 ContentValues domainContentValues = new ContentValues();
368 // Add entries for each field in the certificate.
369 domainContentValues.put(SSL_ISSUED_TO_COMMON_NAME, sslIssuedToCommonName);
370 domainContentValues.put(SSL_ISSUED_TO_ORGANIZATION, sslIssuedToOrganization);
371 domainContentValues.put(SSL_ISSUED_TO_ORGANIZATIONAL_UNIT, sslIssuedToOrganizationalUnit);
372 domainContentValues.put(SSL_ISSUED_BY_COMMON_NAME, sslIssuedByCommonName);
373 domainContentValues.put(SSL_ISSUED_BY_ORGANIZATION, sslIssuedByOrganization);
374 domainContentValues.put(SSL_ISSUED_BY_ORGANIZATIONAL_UNIT, sslIssuedByOrganizationalUnit);
375 domainContentValues.put(SSL_START_DATE, sslStartDate);
376 domainContentValues.put(SSL_END_DATE, sslEndDate);
378 // Get a writable database handle.
379 SQLiteDatabase domainsDatabase = this.getWritableDatabase();
381 // Update the row for `databaseId`. The last argument is `null` because there are no `whereArgs`.
382 domainsDatabase.update(DOMAINS_TABLE, domainContentValues, _ID + " = " + databaseId, null);
384 // Close the database handle.
385 domainsDatabase.close();
388 public void deleteDomain(int databaseId) {
389 // Get a writable database handle.
390 SQLiteDatabase domainsDatabase = this.getWritableDatabase();
392 // Delete the row for `databaseId`. The last argument is `null` because we don't need additional parameters.
393 domainsDatabase.delete(DOMAINS_TABLE, _ID + " = " + databaseId, null);
395 // Close the database handle.
396 domainsDatabase.close();