Skip to content
hamsterksu edited this page Oct 23, 2014 · 1 revision

no-notify feature

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));

Trigger feature

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) {
        .....
    }

Schema and Provider

Define SQL Schema

  1. Declare schema - @Schema
  2. Define sql table - @Table
  3. Define sql view - @SimpleView
  4. Define raw sql query - @RawQuery

Define Content Provider

  1. Declare provider - @Provider
  2. Define provider uri - @URI
  3. Extra provider features - features
Clone this wiki locally