1 /* 2 * Copyright (C) 2007 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 com.example.android.notepad; 18 19 import android.net.Uri; 20 import android.provider.BaseColumns; 21 22 /** 23 * Defines a contract between the Note Pad content provider and its clients. A contract defines the 24 * information that a client needs to access the provider as one or more data tables. A contract 25 * is a public, non-extendable (final) class that contains constants defining column names and 26 * URIs. A well-written client depends only on the constants in the contract. 27 */ 28 public final class NotePad { 29 public static final String AUTHORITY = "com.google.provider.NotePad"; 30 31 // This class cannot be instantiated 32 private NotePad() { 33 } 34 35 /** 36 * Notes table contract 37 */ 38 public static final class Notes implements BaseColumns { 39 40 // This class cannot be instantiated 41 private Notes() {} 42 43 /** 44 * The table name offered by this provider 45 */ 46 public static final String TABLE_NAME = "notes"; 47 48 /* 49 * URI definitions 50 */ 51 52 /** 53 * The scheme part for this provider's URI 54 */ 55 private static final String SCHEME = "content://"; 56 57 /** 58 * Path parts for the URIs 59 */ 60 61 /** 62 * Path part for the Notes URI 63 */ 64 private static final String PATH_NOTES = "/notes"; 65 66 /** 67 * Path part for the Note ID URI 68 */ 69 private static final String PATH_NOTE_ID = "/notes/"; 70 71 /** 72 * 0-relative position of a note ID segment in the path part of a note ID URI 73 */ 74 public static final int NOTE_ID_PATH_POSITION = 1; 75 76 /** 77 * Path part for the Live Folder URI 78 */ 79 private static final String PATH_LIVE_FOLDER = "/live_folders/notes"; 80 81 /** 82 * The content:// style URL for this table 83 */ 84 public static final Uri CONTENT_URI = Uri.parse(SCHEME + AUTHORITY + PATH_NOTES); 85 86 /** 87 * The content URI base for a single note. Callers must 88 * append a numeric note id to this Uri to retrieve a note 89 */ 90 public static final Uri CONTENT_ID_URI_BASE 91 = Uri.parse(SCHEME + AUTHORITY + PATH_NOTE_ID); 92 93 /** 94 * The content URI match pattern for a single note, specified by its ID. Use this to match 95 * incoming URIs or to construct an Intent. 96 */ 97 public static final Uri CONTENT_ID_URI_PATTERN 98 = Uri.parse(SCHEME + AUTHORITY + PATH_NOTE_ID + "/#"); 99 100 /** 101 * The content Uri pattern for a notes listing for live folders 102 */ 103 public static final Uri LIVE_FOLDER_URI 104 = Uri.parse(SCHEME + AUTHORITY + PATH_LIVE_FOLDER); 105 106 /* 107 * MIME type definitions 108 */ 109 110 /** 111 * The MIME type of {@link #CONTENT_URI} providing a directory of notes. 112 */ 113 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.note"; 114 115 /** 116 * The MIME type of a {@link #CONTENT_URI} sub-directory of a single 117 * note. 118 */ 119 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.google.note"; 120 121 /** 122 * The default sort order for this table 123 */ 124 public static final String DEFAULT_SORT_ORDER = "modified DESC"; 125 126 /* 127 * Column definitions 128 */ 129 130 /** 131 * Column name for the title of the note 132 * <P>Type: TEXT</P> 133 */ 134 public static final String COLUMN_NAME_TITLE = "title"; 135 136 /** 137 * Column name of the note content 138 * <P>Type: TEXT</P> 139 */ 140 public static final String COLUMN_NAME_NOTE = "note"; 141 142 /** 143 * Column name for the creation timestamp 144 * <P>Type: INTEGER (long from System.curentTimeMillis())</P> 145 */ 146 public static final String COLUMN_NAME_CREATE_DATE = "created"; 147 148 /** 149 * Column name for the modification timestamp 150 * <P>Type: INTEGER (long from System.curentTimeMillis())</P> 151 */ 152 public static final String COLUMN_NAME_MODIFICATION_DATE = "modified"; 153 } 154 } 155