-
Notifications
You must be signed in to change notification settings - Fork 24
Provider features
hamsterksu edited this page Oct 23, 2014
·
1 revision
If you insert a lot data you should prevent UI update after each insert and make notify when all data is stored.
So use Provider.getNoNotifyContentUri for insert operation and Provider.notifyUri to notify UI about changes.
private static final Uri URI_TEAM_TABLE = FProvider.getNoNotifyContentUri(TeamTable.CONTENT_URI);
.....
cr.bulkInsert(URI_TEAM_TABLE, teams.toArray(new ContentValues[teams.size()]));
.....
FProvider.notifyUri(cr, FProvider.getContentUri(TeamTable.CONTENT_URI));
if you want to call some code before or after some actions in content provider use @Trigger annotation for @URI field.
My trigger is similar to sql trigger :) Plugin will generate specific methods in provider. You should inherit autogenerated provider and override methods.
Define trigger:
@Table(User.TABLE_NAME)
public static interface User{
@Trigger(type=Trigger.Type.INSERT, name="user", when=When.BEFORE)
@URI(altNotify={SuggestionView.URI_CONTENT, MessageChatView.URI_CONTENT, ChatListQuery.URI_CONTENT})
String URI_CONTENT = "user";
Inherid provider:
public class AppProvider extends AppAutoProvider {
@Override
protected void onUserBeforeInserted(ContentValues values) {
.....
}