Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6123777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:03:23+00:00 2026-05-23T16:03:23+00:00

I’m writing my own ContentProvider which will be synced to a web service using

  • 0

I’m writing my own ContentProvider which will be synced to a web service using a SyncAdapter.

Problem happens when the sync adapter is modifying the content provider’s data the provider triggers a network sync when internally calling getContentResolver().notifyChange causing a sync loop.

The notifyChange with the network sync flag is required for when a client application does the modification but should be avoided when the sync adapter is modifying.

How can one, inside a contentprovider, easly tell if it’s being used by a client application (which should trigger network sync upon modification) or by a sync adapter (which should not trigger network sync).

Currently I’m using different CONTENT_URI’s (sync adapter accesses the data using a CONTENT_URI_NO_SYNC and client apps using a CONTENT_URI) to be able to distinguish between the two types of access and set the network sync flag accordingly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:03:23+00:00Added an answer on May 23, 2026 at 4:03 pm

    Watch this video about REST API usage in SyncAdapters.

    The method they discuss is to add a set of metadata flags columns to the database. This allows us to do 3 things.

    1. The flags themselves allow the SyncAdapter to determine the rows that need changes and what those changes are. How do you tell the difference between a locally created row and a locally modified row? Furthermore how do you know which REST API call to make? If you just delete a row, how does your SyncAdapter know the row to be deleted if the data is now gone? Instead, set the “Should be deleted” flag, and then, when the SyncAdapter runs, it knows to push a delete to the server.

    2. The flags allow your CursorAdapter to modify the view that is created (like adding a Spinner to show that “This row is being synced”)

    3. Finally, and this they don’t point out, the flags allow you to tell why the row is being modified. If none of the flags are set and the row changes, it must have been because of an update from the server. Therefore, no need to sync to network.

    So, the two workflows are as follows:

    Local change

    1. App creates new row. Row “create” flag is true.
    2. ContentProvider stores the row, sees create flag and so it calls notifyChange(...,true);
    3. Sync to network = true (the final parameter) causes SyncAdapter to fire.
    4. SyncAdapter scans the database, finds the row with create flag set and performs appropriate server action. After success, SyncAdapter clears the flag.(row update on ContentProvivder)
    5. ContentProvider sees the flag clear, no flags are left set, so it calls notifyChange(…,false);
    6. ContentObservers see the flag change, update to look like “sync finished”

    All these steps are equivalent for update / delete — one flag per syncable row for each of create/update/delete.
    Also notice the other win — what if “Create” fails temporarily? server down… How do you know to retry? — Simple, you don’t clear the “Create” flag and you see it 15 minutes later.

    Remote Change

    1. SyncAdapter fires due to periodic sync.
    2. SyncAdapter fetches an update from the server. Pushes changes into the database. Doesn’t set any flags. ContentProvider sees the lack of flags, knows the change must have come from the server (or isn’t a database change that needs to be pushed to the server), so it calls notifyChange(...,false);
    3. ContentObservers see the content change and so they update with new row data
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.