android - updating listview after inserting row via content provider -


I am using custom ContentProvider to enter and query SQLite database in Android. When I query from the database, I am populating the data on the listview but this problem occurs when I include that row which I also want to update the list view. Custom Adapter is created by increasing Cursor Adapter and LoaderManager.Loader Callbacks , now when I Context.getContentResolver (). Insert () function, I want to update listview

I have tried adapter.notifyDataSetChanged (); After adding the row, but the listview is not updating.

There is only one option I have seen RestartLoader () Any other watt to update the list view?

This is my insert code

  context.getContentResolver (). Insert (ContentUris.withAppendedId (URI.) Expected word (column CONTENT_URI, Columns.INSERT_LOGS), column .LOGS), value);   

I am including the log of the application and showing in the list view

here is the code inside the content provider

  If (rowId> 0) {Ury DartURI = Content uris With expected command (columncontronus, line id); Logs. E ("inserted", line ID + ""); . GetContext () getContentResolver () notifyChange (insertUri, tap). Return entry; }    

I think, you can see how it works, because it Loader .

I had trouble like you and the problem was how I did it.

It was exactly like this.

  @ Override public empty onload loaded (loader & lt; cursor & gt; loader, cursor cursor) {... adapter.swap (cursor) data adapter. NotifyDataSetChanged (); listViewSetAdapter (dataAdapter); ...}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -