My application has a sync adapter created by the structure presented by the Android developers site . The onPerformSync() method onPerformSync() data from the Internet and inserts it into the database with bulk insert:
Vector<ContentValues> cVVector = new Vector<ContentValues>(rssItems.size()); for(RssItem rssItem : rssItems) { ContentValues newsValues = new ContentValues();
In case of conflicts, the database has an IGNORE policy:
final String SQL_CREATE_NEWS_TABLE = "CREATE TABLE " + NewsEntry.TABLE_NAME + " (" + NewsEntry._ID + " INTEGER PRIMARY KEY," + NewsEntry.COLUMN_NEWS_TITTLE + " TEXT UNIQUE NOT NULL, " + NewsEntry.COLUMN_NEWS_CONTENT + " TEXT NOT NULL, " + NewsEntry.COLUMN_NEWS_DESCRIPTION + " TEXT NOT NULL, " + NewsEntry.COLUMN_NEWS_IMAGE + " TEXT, " + NewsEntry.COLUMN_NEWS_DATE + " TEXT NOT NULL, " + NewsEntry.COLUMN_NEWS_LINK + " TEXT NOT NULL, " + "UNIQUE (" + NewsEntry.COLUMN_NEWS_TITTLE +") ON CONFLICT IGNORE"+ " );";
And the sync adapter is configured to sync every 86400 seconds
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) { Account account = getSyncAccount(context); String authority = context.getString(R.string.content_authority); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
However, it is called continuously.
source share