//...@OverridepublicUriinsert(Uriuri,ContentValuescontentValues){mDatabase.insert("items",null,contentValues);returnnull;}@OverridepublicintbulkInsert(Uriuri,ContentValues[]values){intnumInserted=0;mDatabase=mHelper.getWritableDatabase();mDatabase.beginTransaction();try{mDatabase.execSQL("delete from items ; ");mDatabase.execSQL("update sqlite_sequence set seq=0 where name='items'");for(inti=0;i<values.length;i++){insert(uri,values[i]);}mDatabase.setTransactionSuccessful();numInserted=values.length;}catch(Exceptione){e.printStackTrace();}finally{mDatabase.endTransaction();}// sendNotify(uri);returnnumInserted;}privatevoidsendNotify(Uriuri){Stringnotify=uri.getQueryParameter("notify");if(notify==null||notify.equals("true")){getContext().getContentResolver().notifyChange(uri,null);}}//...
privatestaticclassItemDatabaseHelperextendsSQLiteOpenHelper{privatestaticItemDatabaseHelperinstance=null;publicstaticItemDatabaseHelpergetInstance(Contextcontext){if(instance==null){instance=newItemDatabaseHelper(context);}returninstance;}privateItemDatabaseHelper(Contextcontext){super(context,"items",null,DATABASE_VERSION);}@OverridepublicvoidonCreate(SQLiteDatabasedatabase){database.execSQL("create table if not exists items("+" _id integer primary key autoincrement,"+" name text,"+"cid text"+");");}//...}