1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package android.provider; 18 19 import android.accounts.Account; 20 import android.annotation.UnsupportedAppUsage; 21 import android.content.ContentProviderClient; 22 import android.content.ContentProviderOperation; 23 import android.content.ContentResolver; 24 import android.content.ContentUris; 25 import android.content.ContentValues; 26 import android.content.Context; 27 import android.database.Cursor; 28 import android.graphics.BitmapFactory; 29 import android.net.Uri; 30 import android.os.RemoteException; 31 import android.util.Pair; 32 33 /** 34 * <p> 35 * The contract between the browser provider and applications. Contains the definition 36 * for the supported URIS and columns. 37 * </p> 38 * <h3>Overview</h3> 39 * <p> 40 * BrowserContract defines an database of browser-related information which are bookmarks, 41 * history, images and the mapping between the image and URL. 42 * </p> 43 * @hide 44 */ 45 public class BrowserContract { 46 /** The authority for the browser provider */ 47 public static final String AUTHORITY = "com.android.browser"; 48 49 /** A content:// style uri to the authority for the browser provider */ 50 @UnsupportedAppUsage 51 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); 52 53 /** 54 * An optional insert, update or delete URI parameter that allows the caller 55 * to specify that it is a sync adapter. The default value is false. If true 56 * the dirty flag is not automatically set and the "syncToNetwork" parameter 57 * is set to false when calling 58 * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. 59 * @hide 60 */ 61 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; 62 63 /** 64 * A parameter for use when querying any table that allows specifying a limit on the number 65 * of rows returned. 66 * @hide 67 */ 68 public static final String PARAM_LIMIT = "limit"; 69 70 /** 71 * Generic columns for use by sync adapters. The specific functions of 72 * these columns are private to the sync adapter. Other clients of the API 73 * should not attempt to either read or write these columns. 74 * 75 * @hide 76 */ 77 interface BaseSyncColumns { 78 /** Generic column for use by sync adapters. */ 79 public static final String SYNC1 = "sync1"; 80 /** Generic column for use by sync adapters. */ 81 public static final String SYNC2 = "sync2"; 82 /** Generic column for use by sync adapters. */ 83 public static final String SYNC3 = "sync3"; 84 /** Generic column for use by sync adapters. */ 85 public static final String SYNC4 = "sync4"; 86 /** Generic column for use by sync adapters. */ 87 public static final String SYNC5 = "sync5"; 88 } 89 90 /** 91 * Convenience definitions for use in implementing chrome bookmarks sync in the Bookmarks table. 92 * @hide 93 */ 94 public static final class ChromeSyncColumns { ChromeSyncColumns()95 private ChromeSyncColumns() {} 96 97 /** The server unique ID for an item */ 98 public static final String SERVER_UNIQUE = BaseSyncColumns.SYNC3; 99 100 public static final String FOLDER_NAME_ROOT = "google_chrome"; 101 public static final String FOLDER_NAME_BOOKMARKS = "google_chrome_bookmarks"; 102 public static final String FOLDER_NAME_BOOKMARKS_BAR = "bookmark_bar"; 103 public static final String FOLDER_NAME_OTHER_BOOKMARKS = "other_bookmarks"; 104 105 /** The client unique ID for an item */ 106 public static final String CLIENT_UNIQUE = BaseSyncColumns.SYNC4; 107 } 108 109 /** 110 * Columns that appear when each row of a table belongs to a specific 111 * account, including sync information that an account may need. 112 * @hide 113 */ 114 interface SyncColumns extends BaseSyncColumns { 115 /** 116 * The name of the account instance to which this row belongs, which when paired with 117 * {@link #ACCOUNT_TYPE} identifies a specific account. 118 * <P>Type: TEXT</P> 119 */ 120 public static final String ACCOUNT_NAME = "account_name"; 121 122 /** 123 * The type of account to which this row belongs, which when paired with 124 * {@link #ACCOUNT_NAME} identifies a specific account. 125 * <P>Type: TEXT</P> 126 */ 127 public static final String ACCOUNT_TYPE = "account_type"; 128 129 /** 130 * String that uniquely identifies this row to its source account. 131 * <P>Type: TEXT</P> 132 */ 133 public static final String SOURCE_ID = "sourceid"; 134 135 /** 136 * Version number that is updated whenever this row or its related data 137 * changes. 138 * <P>Type: INTEGER</P> 139 */ 140 public static final String VERSION = "version"; 141 142 /** 143 * Flag indicating that {@link #VERSION} has changed, and this row needs 144 * to be synchronized by its owning account. 145 * <P>Type: INTEGER (boolean)</P> 146 */ 147 public static final String DIRTY = "dirty"; 148 149 /** 150 * The time that this row was last modified by a client (msecs since the epoch). 151 * <P>Type: INTEGER</P> 152 */ 153 public static final String DATE_MODIFIED = "modified"; 154 } 155 156 interface CommonColumns { 157 /** 158 * The unique ID for a row. 159 * <P>Type: INTEGER (long)</P> 160 */ 161 public static final String _ID = "_id"; 162 163 /** 164 * This column is valid when the row is a URL. The history table's URL 165 * can not be updated. 166 * <P>Type: TEXT (URL)</P> 167 */ 168 public static final String URL = "url"; 169 170 /** 171 * The user visible title. 172 * <P>Type: TEXT</P> 173 */ 174 public static final String TITLE = "title"; 175 176 /** 177 * The time that this row was created on its originating client (msecs 178 * since the epoch). 179 * <P>Type: INTEGER</P> 180 * @hide 181 */ 182 public static final String DATE_CREATED = "created"; 183 } 184 185 /** 186 * @hide 187 */ 188 interface ImageColumns { 189 /** 190 * The favicon of the bookmark, may be NULL. 191 * Must decode via {@link BitmapFactory#decodeByteArray}. 192 * <p>Type: BLOB (image)</p> 193 */ 194 public static final String FAVICON = "favicon"; 195 196 /** 197 * A thumbnail of the page,may be NULL. 198 * Must decode via {@link BitmapFactory#decodeByteArray}. 199 * <p>Type: BLOB (image)</p> 200 */ 201 public static final String THUMBNAIL = "thumbnail"; 202 203 /** 204 * The touch icon for the web page, may be NULL. 205 * Must decode via {@link BitmapFactory#decodeByteArray}. 206 * <p>Type: BLOB (image)</p> 207 */ 208 public static final String TOUCH_ICON = "touch_icon"; 209 } 210 211 interface HistoryColumns { 212 /** 213 * The date the item was last visited, in milliseconds since the epoch. 214 * <p>Type: INTEGER (date in milliseconds since January 1, 1970)</p> 215 */ 216 public static final String DATE_LAST_VISITED = "date"; 217 218 /** 219 * The number of times the item has been visited. 220 * <p>Type: INTEGER</p> 221 */ 222 public static final String VISITS = "visits"; 223 224 /** 225 * @hide 226 */ 227 public static final String USER_ENTERED = "user_entered"; 228 } 229 230 interface ImageMappingColumns { 231 /** 232 * The ID of the image in Images. One image can map onto the multiple URLs. 233 * <P>Type: INTEGER (long)</P> 234 */ 235 public static final String IMAGE_ID = "image_id"; 236 237 /** 238 * The URL. The URL can map onto the different type of images. 239 * <P>Type: TEXT (URL)</P> 240 */ 241 public static final String URL = "url"; 242 } 243 244 /** 245 * The bookmarks table, which holds the user's browser bookmarks. 246 */ 247 public static final class Bookmarks implements CommonColumns, ImageColumns, SyncColumns { 248 /** 249 * This utility class cannot be instantiated. 250 */ Bookmarks()251 private Bookmarks() {} 252 253 /** 254 * The content:// style URI for this table 255 */ 256 @UnsupportedAppUsage 257 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "bookmarks"); 258 259 /** 260 * Used in {@link Bookmarks#TYPE} column and indicats the row is a bookmark. 261 */ 262 public static final int BOOKMARK_TYPE_BOOKMARK = 1; 263 264 /** 265 * Used in {@link Bookmarks#TYPE} column and indicats the row is a folder. 266 */ 267 public static final int BOOKMARK_TYPE_FOLDER = 2; 268 269 /** 270 * Used in {@link Bookmarks#TYPE} column and indicats the row is the bookmark bar folder. 271 */ 272 public static final int BOOKMARK_TYPE_BOOKMARK_BAR_FOLDER = 3; 273 274 /** 275 * Used in {@link Bookmarks#TYPE} column and indicats the row is other folder and 276 */ 277 public static final int BOOKMARK_TYPE_OTHER_FOLDER = 4; 278 279 /** 280 * Used in {@link Bookmarks#TYPE} column and indicats the row is other folder, . 281 */ 282 public static final int BOOKMARK_TYPE_MOBILE_FOLDER = 5; 283 284 /** 285 * The type of the item. 286 * <P>Type: INTEGER</P> 287 * <p>Allowed values are:</p> 288 * <p> 289 * <ul> 290 * <li>{@link #BOOKMARK_TYPE_BOOKMARK}</li> 291 * <li>{@link #BOOKMARK_TYPE_FOLDER}</li> 292 * <li>{@link #BOOKMARK_TYPE_BOOKMARK_BAR_FOLDER}</li> 293 * <li>{@link #BOOKMARK_TYPE_OTHER_FOLDER}</li> 294 * <li>{@link #BOOKMARK_TYPE_MOBILE_FOLDER}</li> 295 * </ul> 296 * </p> 297 * <p> The TYPE_BOOKMARK_BAR_FOLDER, TYPE_OTHER_FOLDER and TYPE_MOBILE_FOLDER 298 * can not be updated or deleted.</p> 299 */ 300 public static final String TYPE = "type"; 301 302 /** 303 * The content:// style URI for the default folder 304 * @hide 305 */ 306 @UnsupportedAppUsage 307 public static final Uri CONTENT_URI_DEFAULT_FOLDER = 308 Uri.withAppendedPath(CONTENT_URI, "folder"); 309 310 /** 311 * Query parameter used to specify an account name 312 * @hide 313 */ 314 public static final String PARAM_ACCOUNT_NAME = "acct_name"; 315 316 /** 317 * Query parameter used to specify an account type 318 * @hide 319 */ 320 public static final String PARAM_ACCOUNT_TYPE = "acct_type"; 321 322 /** 323 * Builds a URI that points to a specific folder. 324 * @param folderId the ID of the folder to point to 325 * @hide 326 */ 327 @UnsupportedAppUsage buildFolderUri(long folderId)328 public static final Uri buildFolderUri(long folderId) { 329 return ContentUris.withAppendedId(CONTENT_URI_DEFAULT_FOLDER, folderId); 330 } 331 332 /** 333 * The MIME type of {@link #CONTENT_URI} providing a directory of bookmarks. 334 */ 335 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/bookmark"; 336 337 /** 338 * The MIME type of a {@link #CONTENT_URI} of a single bookmark. 339 */ 340 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/bookmark"; 341 342 /** 343 * Query parameter to use if you want to see deleted bookmarks that are still 344 * around on the device and haven't been synced yet. 345 * @see #IS_DELETED 346 * @hide 347 */ 348 public static final String QUERY_PARAMETER_SHOW_DELETED = "show_deleted"; 349 350 /** 351 * Flag indicating if an item is a folder or bookmark. Non-zero values indicate 352 * a folder and zero indicates a bookmark. 353 * <P>Type: INTEGER (boolean)</P> 354 * @hide 355 */ 356 public static final String IS_FOLDER = "folder"; 357 358 /** 359 * The ID of the parent folder. ID 0 is the root folder. 360 * <P>Type: INTEGER (reference to item in the same table)</P> 361 */ 362 public static final String PARENT = "parent"; 363 364 /** 365 * The source ID for an item's parent. Read-only. 366 * @see #PARENT 367 * @hide 368 */ 369 public static final String PARENT_SOURCE_ID = "parent_source"; 370 371 /** 372 * The position of the bookmark in relation to it's siblings that share the same 373 * {@link #PARENT}. May be negative. 374 * <P>Type: INTEGER</P> 375 * @hide 376 */ 377 public static final String POSITION = "position"; 378 379 /** 380 * The item that the bookmark should be inserted after. 381 * May be negative. 382 * <P>Type: INTEGER</P> 383 * @hide 384 */ 385 public static final String INSERT_AFTER = "insert_after"; 386 387 /** 388 * The source ID for the item that the bookmark should be inserted after. Read-only. 389 * May be negative. 390 * <P>Type: INTEGER</P> 391 * @see #INSERT_AFTER 392 * @hide 393 */ 394 public static final String INSERT_AFTER_SOURCE_ID = "insert_after_source"; 395 396 /** 397 * A flag to indicate if an item has been deleted. Queries will not return deleted 398 * entries unless you add the {@link #QUERY_PARAMETER_SHOW_DELETED} query paramter 399 * to the URI when performing your query. 400 * <p>Type: INTEGER (non-zero if the item has been deleted, zero if it hasn't) 401 * @see #QUERY_PARAMETER_SHOW_DELETED 402 * @hide 403 */ 404 public static final String IS_DELETED = "deleted"; 405 } 406 407 /** 408 * Read-only table that lists all the accounts that are used to provide bookmarks. 409 * @hide 410 */ 411 public static final class Accounts { 412 /** 413 * Directory under {@link Bookmarks#CONTENT_URI} 414 */ 415 @UnsupportedAppUsage 416 public static final Uri CONTENT_URI = 417 AUTHORITY_URI.buildUpon().appendPath("accounts").build(); 418 419 /** 420 * The name of the account instance to which this row belongs, which when paired with 421 * {@link #ACCOUNT_TYPE} identifies a specific account. 422 * <P>Type: TEXT</P> 423 */ 424 public static final String ACCOUNT_NAME = "account_name"; 425 426 /** 427 * The type of account to which this row belongs, which when paired with 428 * {@link #ACCOUNT_NAME} identifies a specific account. 429 * <P>Type: TEXT</P> 430 */ 431 public static final String ACCOUNT_TYPE = "account_type"; 432 433 /** 434 * The ID of the account's root folder. This will be the ID of the folder 435 * returned when querying {@link Bookmarks#CONTENT_URI_DEFAULT_FOLDER}. 436 * <P>Type: INTEGER</P> 437 */ 438 public static final String ROOT_ID = "root_id"; 439 } 440 441 /** 442 * The history table, which holds the browsing history. 443 */ 444 public static final class History implements CommonColumns, HistoryColumns, ImageColumns { 445 /** 446 * This utility class cannot be instantiated. 447 */ History()448 private History() {} 449 450 /** 451 * The content:// style URI for this table 452 */ 453 @UnsupportedAppUsage 454 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "history"); 455 456 /** 457 * The MIME type of {@link #CONTENT_URI} providing a directory of browser history items. 458 */ 459 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/browser-history"; 460 461 /** 462 * The MIME type of a {@link #CONTENT_URI} of a single browser history item. 463 */ 464 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/browser-history"; 465 } 466 467 /** 468 * The search history table. 469 * @hide 470 */ 471 public static final class Searches { Searches()472 private Searches() {} 473 474 /** 475 * The content:// style URI for this table 476 */ 477 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "searches"); 478 479 /** 480 * The MIME type of {@link #CONTENT_URI} providing a directory of browser search items. 481 */ 482 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/searches"; 483 484 /** 485 * The MIME type of a {@link #CONTENT_URI} of a single browser search item. 486 */ 487 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/searches"; 488 489 /** 490 * The unique ID for a row. 491 * <P>Type: INTEGER (long)</P> 492 */ 493 public static final String _ID = "_id"; 494 495 /** 496 * The user entered search term. 497 */ 498 public static final String SEARCH = "search"; 499 500 /** 501 * The date the search was performed, in milliseconds since the epoch. 502 * <p>Type: NUMBER (date in milliseconds since January 1, 1970)</p> 503 */ 504 public static final String DATE = "date"; 505 } 506 507 /** 508 * A table provided for sync adapters to use for storing private sync state data. 509 * 510 * @see SyncStateContract 511 * @hide 512 */ 513 public static final class SyncState implements SyncStateContract.Columns { 514 /** 515 * This utility class cannot be instantiated 516 */ SyncState()517 private SyncState() {} 518 519 public static final String CONTENT_DIRECTORY = 520 SyncStateContract.Constants.CONTENT_DIRECTORY; 521 522 /** 523 * The content:// style URI for this table 524 */ 525 public static final Uri CONTENT_URI = 526 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); 527 528 /** 529 * @see android.provider.SyncStateContract.Helpers#get 530 */ get(ContentProviderClient provider, Account account)531 public static byte[] get(ContentProviderClient provider, Account account) 532 throws RemoteException { 533 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); 534 } 535 536 /** 537 * @see android.provider.SyncStateContract.Helpers#get 538 */ getWithUri(ContentProviderClient provider, Account account)539 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) 540 throws RemoteException { 541 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); 542 } 543 544 /** 545 * @see android.provider.SyncStateContract.Helpers#set 546 */ set(ContentProviderClient provider, Account account, byte[] data)547 public static void set(ContentProviderClient provider, Account account, byte[] data) 548 throws RemoteException { 549 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); 550 } 551 552 /** 553 * @see android.provider.SyncStateContract.Helpers#newSetOperation 554 */ newSetOperation(Account account, byte[] data)555 public static ContentProviderOperation newSetOperation(Account account, byte[] data) { 556 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); 557 } 558 } 559 560 /** 561 * <p> 562 * Stores images for URLs. 563 * </p> 564 * <p> 565 * The rows in this table can not be updated since there might have multiple URLs mapping onto 566 * the same image. If you want to update a URL's image, you need to add the new image in this 567 * table, then update the mapping onto the added image. 568 * </p> 569 * <p> 570 * Every image should be at least associated with one URL, otherwise it will be removed after a 571 * while. 572 * </p> 573 */ 574 public static final class Images implements ImageColumns { 575 /** 576 * This utility class cannot be instantiated 577 */ Images()578 private Images() {} 579 580 /** 581 * The content:// style URI for this table 582 */ 583 @UnsupportedAppUsage 584 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "images"); 585 586 /** 587 * The MIME type of {@link #CONTENT_URI} providing a directory of images. 588 */ 589 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/images"; 590 591 /** 592 * The MIME type of a {@link #CONTENT_URI} of a single image. 593 */ 594 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/images"; 595 596 /** 597 * Used in {@link Images#TYPE} column and indicats the row is a favicon. 598 */ 599 public static final int IMAGE_TYPE_FAVICON = 1; 600 601 /** 602 * Used in {@link Images#TYPE} column and indicats the row is a precomposed touch icon. 603 */ 604 public static final int IMAGE_TYPE_PRECOMPOSED_TOUCH_ICON = 2; 605 606 /** 607 * Used in {@link Images#TYPE} column and indicats the row is a touch icon. 608 */ 609 public static final int IMAGE_TYPE_TOUCH_ICON = 4; 610 611 /** 612 * The type of item in the table. 613 * <P>Type: INTEGER</P> 614 * <p>Allowed values are:</p> 615 * <p> 616 * <ul> 617 * <li>{@link #IMAGE_TYPE_FAVICON}</li> 618 * <li>{@link #IMAGE_TYPE_PRECOMPOSED_TOUCH_ICON}</li> 619 * <li>{@link #IMAGE_TYPE_TOUCH_ICON}</li> 620 * </ul> 621 * </p> 622 */ 623 public static final String TYPE = "type"; 624 625 /** 626 * The image data. 627 * <p>Type: BLOB (image)</p> 628 */ 629 public static final String DATA = "data"; 630 631 /** 632 * The URL the images came from. 633 * <P>Type: TEXT (URL)</P> 634 * @hide 635 */ 636 public static final String URL = "url_key"; 637 } 638 639 /** 640 * <p> 641 * A table that stores the mappings between the image and the URL. 642 * </p> 643 * <p> 644 * Deleting or Updating a mapping might also deletes the mapped image if there is no other URL 645 * maps onto it. 646 * </p> 647 */ 648 public static final class ImageMappings implements ImageMappingColumns { 649 /** 650 * This utility class cannot be instantiated 651 */ ImageMappings()652 private ImageMappings() {} 653 654 /** 655 * The content:// style URI for this table 656 */ 657 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "image_mappings"); 658 659 /** 660 * The MIME type of {@link #CONTENT_URI} providing a directory of image mappings. 661 */ 662 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/image_mappings"; 663 664 /** 665 * The MIME type of a {@link #CONTENT_URI} of a single image mapping. 666 */ 667 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/image_mappings"; 668 } 669 670 /** 671 * A combined view of bookmarks and history. All bookmarks in all folders are included and 672 * no folders are included. 673 * @hide 674 */ 675 public static final class Combined implements CommonColumns, HistoryColumns, ImageColumns { 676 /** 677 * This utility class cannot be instantiated 678 */ Combined()679 private Combined() {} 680 681 /** 682 * The content:// style URI for this table 683 */ 684 @UnsupportedAppUsage 685 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "combined"); 686 687 /** 688 * Flag indicating that an item is a bookmark. A value of 1 indicates a bookmark, a value 689 * of 0 indicates a history item. 690 * <p>Type: INTEGER (boolean)</p> 691 */ 692 public static final String IS_BOOKMARK = "bookmark"; 693 } 694 695 /** 696 * A table that stores settings specific to the browser. Only support query and insert. 697 * @hide 698 */ 699 public static final class Settings { 700 /** 701 * This utility class cannot be instantiated 702 */ Settings()703 private Settings() {} 704 705 /** 706 * The content:// style URI for this table 707 */ 708 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "settings"); 709 710 /** 711 * Key for a setting value. 712 */ 713 public static final String KEY = "key"; 714 715 /** 716 * Value for a setting. 717 */ 718 public static final String VALUE = "value"; 719 720 /** 721 * If set to non-0 the user has opted into bookmark sync. 722 */ 723 public static final String KEY_SYNC_ENABLED = "sync_enabled"; 724 725 /** 726 * Returns true if bookmark sync is enabled 727 */ isSyncEnabled(Context context)728 static public boolean isSyncEnabled(Context context) { 729 Cursor cursor = null; 730 try { 731 cursor = context.getContentResolver().query(CONTENT_URI, new String[] { VALUE }, 732 KEY + "=?", new String[] { KEY_SYNC_ENABLED }, null); 733 if (cursor == null || !cursor.moveToFirst()) { 734 return false; 735 } 736 return cursor.getInt(0) != 0; 737 } finally { 738 if (cursor != null) cursor.close(); 739 } 740 } 741 742 /** 743 * Sets the bookmark sync enabled setting. 744 */ setSyncEnabled(Context context, boolean enabled)745 static public void setSyncEnabled(Context context, boolean enabled) { 746 ContentValues values = new ContentValues(); 747 values.put(KEY, KEY_SYNC_ENABLED); 748 values.put(VALUE, enabled ? 1 : 0); 749 context.getContentResolver().insert(CONTENT_URI, values); 750 } 751 } 752 } 753