java - content provider -
i had created class extends contentprovider. had override 6 functions
@override public uri insert(uri uri, contentvalues initialvalues) { contentvalues values; if(initialvalues != null){ values = new contentvalues(initialvalues); }else{ values = new contentvalues(); } sqlitedatabase mdb = mdbhelper.getwritabledatabase(); long rowid = mdb.insert(databasehelper.table_program, null, values); if(rowid > 0){ uri programuri = contenturis.withappendedid(null, rowid); getcontext().getcontentresolver().notifychange(programuri, null); return programuri; } throw new illegalargumentexception("failed insert row " + uri); } private void createdata(){ string = "a", b = "b", c = "c", d= "d"; //how going call content provider let me add in data? }
my question how call insert() add data?
obtain contentresolver instance via getcontentresolver() insert method.
update that's best tutorial
Comments
Post a Comment