First pass at new ContactsProvider.

It's very basic right now, but shows the general layout that I'm
thinking of for the schema and how the data types are defined.

The test app just reads the display names and puts them in a list,
not very useful since you have to add data with the sqlite3 tool
for now.
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..7f1871a
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,16 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := user
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_JAVA_LIBRARIES := ext
+
+LOCAL_PACKAGE_NAME := ContactsProvider2
+LOCAL_CERTIFICATE := shared
+
+include $(BUILD_PACKAGE)
+
+# Use the following include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..86f73d6
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,21 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.providers.contacts2"
+    android:sharedUserId="android.uid.shared"
+>
+
+    <uses-permission android:name="android.permission.READ_CONTACTS" />
+    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+
+    <application
+        android:process="android.process.acore"
+        android:label="ContactsProvider2"
+    >
+        <provider android:name="ContactsProvider2"
+            android:authorities="com.android.contacts"
+            android:syncable="false"
+            android:multiprocess="false"
+            android:readPermission="android.permission.READ_CONTACTS"
+            android:writePermission="android.permission.WRITE_CONTACTS"
+        />
+    </application>
+</manifest>
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_APACHE2
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..c5b1efa
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,190 @@
+
+   Copyright (c) 2005-2008, The Android Open Source Project
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
diff --git a/src/com/android/providers/contacts2/ContactsContract.java b/src/com/android/providers/contacts2/ContactsContract.java
new file mode 100644
index 0000000..041d718
--- /dev/null
+++ b/src/com/android/providers/contacts2/ContactsContract.java
@@ -0,0 +1,364 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.providers.contacts2;
+
+import android.net.Uri;
+import android.provider.BaseColumns;
+
+/**
+ * The contract between the contacts provider and applications. Contains definitions
+ * for the supported URIs and columns.
+ *
+ * TODO: move to android.provider
+ */
+public final class ContactsContract {
+    public static final String AUTHORITY = "com.android.contacts";
+    public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
+
+    private interface ContactsColumns {
+        /**
+         * The given name for the contact.
+         * <P>Type: TEXT</P>
+         */
+        public static final String GIVEN_NAME = "given_name";
+
+        /**
+         * The phonetic version of the given name for the contact.
+         * <P>Type: TEXT</P>
+         */
+        public static final String PHONETIC_GIVEN_NAME = "phonetic_given_name";
+
+        /**
+         * The family name for the contact.
+         * <P>Type: TEXT</P>
+         */
+        public static final String FAMILY_NAME = "family_name";
+
+        /**
+         * The phonetic version of the family name for the contact.
+         * <P>Type: TEXT</P>
+         */
+        public static final String PHONETIC_FAMILY_NAME = "phonetic_given_name";
+
+        /**
+         * The display name for the contact.
+         * <P>Type: TEXT</P>
+         */
+        public static final String DISPLAY_NAME = "display_name";
+
+        /**
+         * The number of times a person has been contacted
+         * <P>Type: INTEGER</P>
+         */
+        public static final String TIMES_CONTACTED = "times_contacted";
+
+        /**
+         * The last time a person was contacted.
+         * <P>Type: INTEGER</P>
+         */
+        public static final String LAST_TIME_CONTACTED = "last_time_contacted";
+
+        /**
+         * A custom ringtone associated with a person. Not always present.
+         * <P>Type: TEXT (URI to the ringtone)</P>
+         */
+        public static final String CUSTOM_RINGTONE = "custom_ringtone";
+
+        /**
+         * Whether the person should always be sent to voicemail. Not always
+         * present.
+         * <P>Type: INTEGER (0 for false, 1 for true)</P>
+         */
+        public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
+
+        /**
+         * Is the contact starred?
+         * <P>Type: INTEGER (boolean)</P>
+         */
+        public static final String STARRED = "starred";
+    }
+
+    /**
+     * Constants for the contacts table, which contains the base contact information.
+     */
+    public static final class Contacts implements BaseColumns, ContactsColumns {
+        /**
+         * This utility class cannot be instantiated
+         */
+        private Contacts()  {}
+
+        /**
+         * The content:// style URI for this table
+         */
+        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
+
+        /**
+         * The MIME type of {@link #CONTENT_URI} providing a directory of
+         * people.
+         */
+        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/person";
+
+        /**
+         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
+         * person.
+         */
+        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/person";
+    }
+
+    private interface DataColumns {
+        /**
+         * The package name that defines this type of data.
+         */
+        public static final String PACKAGE = "package";
+
+        /**
+         * The kind of the data, scoped within the package stored in {@link #PACKAGE}.
+         */
+        public static final String KIND = "kind";
+
+        /**
+         * A reference to the {@link Contacts#_ID} that this data belongs to.
+         */
+        public static final String CONTACT_ID = "contact_id";
+
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA1 = "data1";
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA2 = "data2";
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA3 = "data3";
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA4 = "data4";
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA5 = "data5";
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA6 = "data6";
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA7 = "data7";
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA8 = "data8";
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA9 = "data9";
+        /** Generic data column, the meaning is {@link #KIND} specific */
+        public static final String DATA10 = "data10";
+    }
+
+    /**
+     * Constants for the data table, which contains data points tied to a contact.
+     * For example, a phone number or email address. Each row in this table contains a type
+     * definition and some generic columns. Each data type can define the meaning for each of
+     * the generic columns.
+     */
+    public static final class Data implements BaseColumns, DataColumns {
+        /**
+         * This utility class cannot be instantiated
+         */
+        private Data() {}
+
+        /**
+         * The content:// style URI for this table
+         */
+        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
+
+    }
+
+    /**
+     * Container for definitions of common data types stored in the {@link Data} table.
+     */
+    public static final class CommonDataKinds {
+        /** The {@link Data#PACKAGE} value for the common data kinds */
+        public static final String PACKAGE_COMMON = "common";
+
+        /**
+         * Columns common across the specific types.
+         */
+        private interface CommonColumns {
+            /**
+             * The type of data, for example Home or Work.
+             * <P>Type: INTEGER</P>
+             */
+            public static final String TYPE = "data1";
+
+            /**
+             * The user defined label for the the contact method.
+             * <P>Type: TEXT</P>
+             */
+            public static final String LABEL = "data2";
+
+            /**
+             * The data for the contact method.
+             * <P>Type: TEXT</P>
+             */
+            public static final String DATA = "data3";
+
+            /**
+             * Whether this is the primary entry of its kind for the contact it belongs to
+             * <P>Type: INTEGER (if set, non-0 means true)</P>
+             */
+            public static final String ISPRIMARY = "data4";
+        }
+
+        /**
+         * Common data definition for telephone numbers.
+         */
+        public static final class Phone {
+            private Phone() {}
+
+            /** Signifies a phone number row that is stored in the data table */
+            public static final int KIND = 5;
+
+            /**
+             * The type of data, for example Home or Work.
+             * <P>Type: INTEGER</P>
+             */
+            public static final String TYPE = "data1";
+
+            public static final int TYPE_CUSTOM = 0;
+            public static final int TYPE_HOME = 1;
+            public static final int TYPE_MOBILE = 2;
+            public static final int TYPE_WORK = 3;
+            public static final int TYPE_FAX_WORK = 4;
+            public static final int TYPE_FAX_HOME = 5;
+            public static final int TYPE_PAGER = 6;
+            public static final int TYPE_OTHER = 7;
+
+            /**
+             * The user provided label, only used if TYPE is {@link #TYPE_CUSTOM}.
+             * <P>Type: TEXT</P>
+             */
+            public static final String LABEL = "data2";
+
+            /**
+             * The phone number as the user entered it.
+             * <P>Type: TEXT</P>
+             */
+            public static final String NUMBER = "data3";
+
+            /**
+             * The normalized phone number
+             * <P>Type: TEXT</P>
+             */
+            public static final String NUMBER_KEY = "data4";
+
+            /**
+             * Whether this is the primary phone number
+             * <P>Type: INTEGER (if set, non-0 means true)</P>
+             */
+            public static final String ISPRIMARY = "data5";
+        }
+
+        /**
+         * Common data definition for email addresses.
+         */
+        public static final class Email implements CommonColumns {
+            private Email() {}
+
+            /** Signifies an email address row that is stored in the data table */
+            public static final int KIND = 1;
+
+            public static final int TYPE_CUSTOM = 0;
+            public static final int TYPE_HOME = 1;
+            public static final int TYPE_WORK = 2;
+            public static final int TYPE_OTHER = 3;
+        }
+
+        /**
+         * Common data definition for postal addresses.
+         */
+        public static final class Postal implements CommonColumns {
+            private Postal() {}
+
+            /** Signifies a postal address row that is stored in the data table */
+            public static final int KIND = 2;
+
+            public static final int TYPE_CUSTOM = 0;
+            public static final int TYPE_HOME = 1;
+            public static final int TYPE_WORK = 2;
+            public static final int TYPE_OTHER = 3;
+        }
+
+       /**
+        * Common data definition for IM addresses.
+        */
+        public static final class Im implements CommonColumns {
+            private Im() {}
+
+            /** Signifies an IM address row that is stored in the data table */
+            public static final int KIND = 3;
+
+            public static final int TYPE_CUSTOM = 0;
+            public static final int TYPE_HOME = 1;
+            public static final int TYPE_WORK = 2;
+            public static final int TYPE_OTHER = 3;
+        }
+
+        /**
+         * Common data definition for organizations.
+         */
+        public static final class Organization {
+            private Organization() {}
+
+            /** Signifies an organization row that is stored in the data table */
+            public static final int KIND = 4;
+
+            public static final int TYPE_CUSTOM = 0;
+            public static final int TYPE_HOME = 1;
+            public static final int TYPE_WORK = 2;
+            public static final int TYPE_OTHER = 3;
+
+            /**
+             * The user provided label, only used if TYPE is {@link #TYPE_CUSTOM}.
+             * <P>Type: TEXT</P>
+             */
+            public static final String LABEL = "label";
+
+            /**
+             * The name of the company for this organization.
+             * <P>Type: TEXT</P>
+             */
+            public static final String COMPANY = "company";
+
+            /**
+             * The title within this organization.
+             * <P>Type: TEXT</P>
+             */
+            public static final String TITLE = "title";
+
+            /**
+             * Whether this is the primary organization
+             * <P>Type: INTEGER (if set, non-0 means true)</P>
+             */
+            public static final String ISPRIMARY = "isprimary";
+        }
+
+        /**
+         * Notes about the contact.
+         */
+        public static final class Note {
+            private Note() {}
+
+            /** Signifies a free-form note row that is stored in the data table */
+            public static final int KIND = 6;
+
+            /**
+             * The note text.
+             * <P>Type: TEXT</P>
+             */
+            public static final String NOTE = "data1";
+        }
+    }
+}
diff --git a/src/com/android/providers/contacts2/ContactsProvider2.java b/src/com/android/providers/contacts2/ContactsProvider2.java
new file mode 100644
index 0000000..050e0ee
--- /dev/null
+++ b/src/com/android/providers/contacts2/ContactsProvider2.java
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.providers.contacts2;
+
+import com.android.providers.contacts2.ContactsContract.Contacts;
+import com.android.providers.contacts2.ContactsContract.Data;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.database.sqlite.SQLiteQueryBuilder;
+import android.net.Uri;
+import android.util.Log;
+
+import java.util.HashMap;
+
+/**
+ * Contacts content provider. The contract between this provider and applications
+ * is defined in {@link ContactsContract}.
+ */
+public class ContactsProvider2 extends ContentProvider {
+    private static final String TAG = "~~~~~~~~~~~~~"; // TODO: set to class name
+
+    private static final int DATABASE_VERSION = 4;
+    private static final String DATABASE_NAME = "contacts2.db";
+
+    private static final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+
+    private static final int CONTACTS = 1000;
+    private static final int CONTACTS_ID = 1001;
+
+    private static final int DATA = 2000;
+    private static final int DATA_ID = 2001;
+
+    private static final HashMap<String, String> sContactsProjectionMap;
+    private static final HashMap<String, String> sDataProjectionMap;
+
+    static {
+        // Contacts URI matching table
+        final UriMatcher matcher = sURIMatcher;
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts", CONTACTS);
+        matcher.addURI(ContactsContract.AUTHORITY, "contacts/#", CONTACTS_ID);
+        matcher.addURI(ContactsContract.AUTHORITY, "data", DATA);
+        matcher.addURI(ContactsContract.AUTHORITY, "data/#", DATA_ID);
+
+        HashMap<String, String> columns;
+
+        // Contacts projection map
+        columns = new HashMap<String, String>();
+        columns.put(Contacts._ID, "contacts._id AS _id");
+        columns.put(Contacts.GIVEN_NAME, Contacts.GIVEN_NAME);
+        columns.put(Contacts.PHONETIC_GIVEN_NAME, Contacts.PHONETIC_GIVEN_NAME);
+        columns.put(Contacts.FAMILY_NAME, Contacts.FAMILY_NAME);
+        columns.put(Contacts.PHONETIC_FAMILY_NAME, Contacts.PHONETIC_FAMILY_NAME);
+        columns.put(Contacts.DISPLAY_NAME,
+                Contacts.GIVEN_NAME + " || ' ' || " + Contacts.FAMILY_NAME +
+                " AS " + Contacts.DISPLAY_NAME);
+        sContactsProjectionMap = columns;
+
+        // Data projection map
+        columns = new HashMap<String, String>();
+        columns.put(Data._ID, "data._id AS _id");
+        columns.put(Data.CONTACT_ID, Data.CONTACT_ID);
+        columns.put(Data.PACKAGE, Data.PACKAGE);
+        columns.put(Data.KIND, Data.KIND);
+        columns.put(Data.DATA1, Data.DATA1);
+        columns.put(Data.DATA2, Data.DATA2);
+        columns.put(Data.DATA3, Data.DATA3);
+        columns.put(Data.DATA4, Data.DATA4);
+        columns.put(Data.DATA5, Data.DATA5);
+        columns.put(Data.DATA6, Data.DATA6);
+        columns.put(Data.DATA7, Data.DATA7);
+        columns.put(Data.DATA8, Data.DATA8);
+        columns.put(Data.DATA9, Data.DATA9);
+        columns.put(Data.DATA10, Data.DATA10);
+        sDataProjectionMap = columns;
+    }
+
+    private OpenHelper mOpenHelper;
+
+    private class OpenHelper extends SQLiteOpenHelper {
+        public OpenHelper() {
+            super(getContext(), DATABASE_NAME, null, DATABASE_VERSION);
+            Log.i(TAG, "Creating OpenHelper");
+        }
+
+        @Override
+        public void onCreate(SQLiteDatabase db) {
+            Log.i(TAG, "Bootstrapping database");
+
+            db.execSQL("CREATE TABLE contacts (" +
+                    Contacts._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
+                    Contacts.GIVEN_NAME + " TEXT," +
+                    Contacts.FAMILY_NAME + " TEXT," +
+                    Contacts.TIMES_CONTACTED + " INTEGER," +
+                    Contacts.LAST_TIME_CONTACTED + " INTEGER," +
+                    Contacts.CUSTOM_RINGTONE + " TEXT," +
+                    Contacts.SEND_TO_VOICEMAIL + " INTEGER," +
+                    Contacts.STARRED + " INTEGER" +
+            ");");
+
+            db.execSQL("CREATE TABLE data (" +
+                    Data._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
+                    Data.CONTACT_ID + " INTEGER NOT NULL," +
+                    Data.PACKAGE + " TEXT NOT NULL," +
+                    Data.KIND + " INTEGER NOT NULL," +
+                    Data.DATA1 + " TEXT," +
+                    Data.DATA2 + " TEXT," +
+                    Data.DATA3 + " TEXT," +
+                    Data.DATA4 + " TEXT," +
+                    Data.DATA5 + " TEXT," +
+                    Data.DATA6 + " TEXT," +
+                    Data.DATA7 + " TEXT," +
+                    Data.DATA8 + " TEXT," +
+                    Data.DATA9 + " TEXT," +
+                    Data.DATA10 + " TEXT" +
+            ");");
+        }
+
+        @Override
+        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+            Log.i(TAG, "Upgraing from version " + oldVersion + " to " + newVersion
+                    + ", data will be lost!");
+
+            db.execSQL("DROP TABLE IF EXISTS contacts;");
+            db.execSQL("DROP TABLE IF EXISTS data;");
+
+            onCreate(db);
+        }
+    }
+
+    @Override
+    public boolean onCreate() {
+        mOpenHelper = new OpenHelper();
+
+        // TODO remove this, it's here to force opening the database on boot for testing
+        mOpenHelper.getReadableDatabase();
+
+        return true;
+    }
+
+    @Override
+    public boolean isTemporary() {
+        return false;
+    }
+
+    @Override
+    public Uri insert(Uri uri, ContentValues values) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public int delete(Uri uri, String selection, String[] selectionArgs) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+        return 0;
+    }
+
+    @Override
+    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+            String sortOrder) {
+        final SQLiteDatabase db = mOpenHelper.getReadableDatabase();
+        final SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
+
+        final int match = sURIMatcher.match(uri);
+        switch (match) {
+            case CONTACTS: {
+                qb.setTables("contacts");
+                qb.setProjectionMap(sContactsProjectionMap);
+                break;
+            }
+
+            case CONTACTS_ID: {
+                qb.setTables("contacts");
+                qb.setProjectionMap(sContactsProjectionMap);
+                qb.appendWhere("_id = " + uri.getLastPathSegment());
+                break;
+            }
+
+            case DATA: {
+                qb.setTables("data");
+                qb.setProjectionMap(sDataProjectionMap);
+                break;
+            }
+
+            case DATA_ID: {
+                qb.setTables("data");
+                qb.setProjectionMap(sDataProjectionMap);
+                qb.appendWhere("_id = " + uri.getLastPathSegment());
+                break;
+            }
+
+            default:
+                throw new UnsupportedOperationException("Unknown uri: " + uri);
+        }
+
+        // Perform the query and set the notification uri
+        final Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder);
+        if (c != null) {
+            c.setNotificationUri(getContext().getContentResolver(), ContactsContract.AUTHORITY_URI);
+        }
+        return c;
+    }
+
+    @Override
+    public String getType(Uri uri) {
+        final int match = sURIMatcher.match(uri);
+        switch (match) {
+            case CONTACTS: return Contacts.CONTENT_TYPE;
+            case CONTACTS_ID: return Contacts.CONTENT_ITEM_TYPE;
+        }
+        return null;
+    }
+}
diff --git a/tests/Android.mk b/tests/Android.mk
new file mode 100644
index 0000000..7eebbe0
--- /dev/null
+++ b/tests/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := user
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SRC_FILES += ../src/com/android/providers/contacts2/ContactsContract.java
+
+LOCAL_PACKAGE_NAME := Contacts2
+
+include $(BUILD_PACKAGE)
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
new file mode 100644
index 0000000..f2a9bb7
--- /dev/null
+++ b/tests/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.contacts2"
+>
+
+    <uses-permission android:name="android.permission.READ_CONTACTS" />
+    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+
+    <application android:label="@string/app_name">
+        <activity android:name="Contacts2">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+</manifest>
diff --git a/tests/res/values/strings.xml b/tests/res/values/strings.xml
new file mode 100644
index 0000000..a7b49f1
--- /dev/null
+++ b/tests/res/values/strings.xml
@@ -0,0 +1,4 @@
+<resources>
+    <string name="app_name">Contacts2</string>
+</resources>
+
diff --git a/tests/src/com/android/contacts2/Contacts2.java b/tests/src/com/android/contacts2/Contacts2.java
new file mode 100644
index 0000000..e31ec4a
--- /dev/null
+++ b/tests/src/com/android/contacts2/Contacts2.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.contacts2;
+
+import com.android.providers.contacts2.ContactsContract.Contacts;
+
+import android.app.ListActivity;
+import android.database.Cursor;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.widget.SimpleCursorAdapter;
+
+public class Contacts2 extends ListActivity {
+    static final String[] PROJECTION = {
+        Contacts._ID, // 0
+        Contacts.DISPLAY_NAME, // 1
+    };
+    static final int COLUMN_INDEX_ID = 0;
+    static final int COLUMN_INDEX_DISPLAY_NAME = 1;
+
+    SimpleCursorAdapter mAdapter;
+
+    public class QueryTask extends AsyncTask<Void, Void, Cursor> {
+        @Override
+        protected Cursor doInBackground(Void... params) {
+            final Cursor c = getContentResolver().query(Contacts.CONTENT_URI, PROJECTION, null,
+                    null, Contacts.DISPLAY_NAME + " ASC");
+            if (c != null) {
+                c.getCount();
+            }
+            return c;
+        }
+
+        @Override
+        protected void onPostExecute(Cursor c) {
+            if (isFinishing()) {
+                if (c != null) {
+                    c.close();
+                }
+                return;
+            }
+
+            mAdapter.changeCursor(c);
+        }
+    }
+
+    @Override
+    public void onCreate(Bundle savedState) {
+        super.onCreate(savedState);
+
+        mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
+                new String[] { Contacts.DISPLAY_NAME }, new int[] { android.R.id.text1 });
+        setListAdapter(mAdapter);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+
+        new QueryTask().execute((Void[]) null);
+    }
+}