- // Set the consent status to Unknown.
- ConsentInformation.getInstance(getActivity().getApplicationContext()).setConsentStatus(ConsentStatus.UNKNOWN);
+ // Remove the incorrect lint warning below that `getApplicationContext()` might be null.
+ assert getActivity() != null;
+
+ // Initialize the bookmarks database helper. The `0` specifies a database version, but that is ignored and set instead using a constant in `AdConsentDatabaseHelper`.
+ // `getContext()` can be used instead of `getActivity.getApplicationContext()` when the minimum API >= 23.
+ AdConsentDatabaseHelper adConsentDatabaseHelper = new AdConsentDatabaseHelper(getActivity().getApplicationContext(), null, null, 0);
+
+ // Update the ad consent database.
+ adConsentDatabaseHelper.updateAdConsent(false);