android - updating listview after inserting row via content provider -



android - updating listview after inserting row via content provider -

i using custom contentprovider insert , query sqlite database in android. when query database populating info on listview. issue when insert row want update listview also.

i have created custom adapter extending cursoradapter , listening loadermanager.loadercallbacks<cursor> , when when inserting row context.getcontentresolver().insert() function , want update listview.

i have tried adapter.notifydatasetchanged(); after inserting row listview not getting updated.

the alternative saw restartloader() there anyother wat update listview ?

this insert code

context.getcontentresolver().insert( contenturis.withappendedid( uri.withappendedpath(columns.content_uri, columns.insert_logs ), columns.logs), values);

i inserting logs of application , showing listview

here code within content provider

if(rowid > 0 ){ uri inserturi = contenturis.withappendedid(columns.content_uri, rowid); log.e("inserted " , rowid+""); getcontext().getcontentresolver().notifychange(inserturi,null); homecoming inserturi; }

i think, can see how works this example, because it's based on loaders.

please take @ too.

i had troubles , problem how did.

it right this.

@override public void onloadfinished(loader<cursor> loader, cursor cursor) { ... adapter.swap(cursor) dataadapter.notifydatasetchanged(); listview.setadapter(dataadapter); ... }

android listview android-listview android-contentprovider

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -