1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3 
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License
16  */
17 
18 package com.android.providers.contacts;
19 
20 import android.content.ContentValues;
21 import android.database.DatabaseUtils;
22 import android.database.sqlite.SQLiteDatabase;
23 import android.net.Uri;
24 
25 /**
26  * An interface which wraps key database modify operations (insert, update, delete) to perform
27  * additional tasks before or after the database modification operation. A typical use case is to
28  * generate notification when a database is modified.
29  */
30 public interface DatabaseModifier {
31     /**
32      * Use this method to insert a value which you would otherwise do using the
33      * {@link SQLiteDatabase#insert(String, String, ContentValues)} method.
34      */
insert(String table, String nullColumnHack, ContentValues values)35     public abstract long insert(String table, String nullColumnHack, ContentValues values);
36     /**
37      * Use this method to insert a value which you would otherwise do using the
38      * {@link DatabaseUtils.InsertHelper#insert(ContentValues)} method.
39      */
insert(ContentValues values)40     public abstract long insert(ContentValues values);
41     /**
42      * Use this method to update a table which you would otherwise do using the
43      * {@link SQLiteDatabase#update(String, ContentValues, String, String[])} method.
44      */
update(Uri uri, String table, ContentValues values, String whereClause, String[] whereArgs)45     public abstract int update(Uri uri, String table, ContentValues values,
46             String whereClause, String[] whereArgs);
47     /**
48      * Use this method to delete entries from a table which you would otherwise do using the
49      * {@link SQLiteDatabase#delete(String, String, String[])} method.
50      */
delete(String table, String whereClause, String[] whereArgs)51     public abstract int delete(String table, String whereClause, String[] whereArgs);
52 
startBulkOperation()53     void startBulkOperation();
54 
yieldBulkOperation()55     void yieldBulkOperation();
56 
finishBulkOperation()57     void finishBulkOperation();
58 }
59