robotoworks / mechanoid

Eclipse plugin providing a set of DSL's for the rapid development of Android apps
58 stars 26 forks source link

force loader refresh without change anything #243

Closed hannesa2 closed 10 years ago

hannesa2 commented 10 years ago

Is there a elegant way to force a

public Loader<Cursor> onCreateLoader(...

normally I do this (works like a charm)

myTableRecord.setMyValue("something");
myTableRecord.save();

but when I do some sophisticated updates with ndk direct on database, I want inform my loaders to restart without any dummy update like at the top

fluxtah commented 10 years ago

This is how we do it in our app

context.getContentResolver().notifyChange(Baskets.CONTENT_URI, null);

Where Baskets is the table or view we want to notify of an update

hannesa2 commented 10 years ago

perfect ! Thank you

hannesa2 commented 10 years ago

do you know, when I do bulk inserts like

 getContentResolver().bulkInsert(Recipes.CONTENT_URI, values);

does the ContentResolver reflect the insert with a notification ? If yes, is there a way the prevent my app doing so ?

fluxtah commented 10 years ago

Yes I think it does, but you can control it with a Uri parameter, ie:-

Uri uri = Recipes.CONTENT_URI
    .buildUpon()
    .appendQueryParameter(MechanoidContentProvider.PARAM_NOTIFY, "false")
    .build();

   getContentResolver().bulkInsert(uri, values);

This is what the records and builders do under the hood :)

hannesa2 commented 10 years ago

perfect ! Thank you