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 8544383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:32:39+00:00 2026-06-11T12:32:39+00:00

I know that this question has been asked too many times, but I think

  • 0

I know that this question has been asked too many times, but I think the issues I’m trying to target are a little bit different, maybe more complicated.

I am going to develop an application that uses a RESTful Web Service and needs to have the following requirements:

  • the app should show some books, their authors and their editors in lists and in detail

  • the app should also allow searching for a book

  • books, authors and editors are fetched from a RESTful web service

  • every entity has to be cached so that when I open an Activity I see the old data first (if any), while the new one updates from the network.

  • every time an entity is updating, the interested parties should be notified (ContentObserver? A regular Listener implementation?)

  • if a call is already executing (say to api/books/1337 or to api/editors) the caller should be notified that it is loading data and should be given the old one (if it exists), as if it was the original caller.

  • some data (only books and authors) should be updated every N minutes (decided by the user) and the observers should be notified (SyncAdapter?)

Questions:

After watching and studying all of the components proposed by Virgil Dobjanschi at Google I/O 2010 here are my doubts:

  1. How can I transparently handle the “entity-is-updating” concept for any caller? Should I use ContentObserver on a ContentProvider I will have to implement?

  2. If I use a ContentObserver I can easily set a status-flag for the single entity (as suggested by Dobjanschi), for example UPDATING, INSERTING, and so on. But how should I handle list? Say I want a list of books, where should I put the status flag? Should I put it in a status table for lists only? If so, I should observe two Cursors, one for the status and one for the actual list (i.e., the table/Content URI). And what if the entity I’m asking for does not exists (yet) or the REST call returns a 404? How do I handle the callback?

  3. If I put all of my REST methods in a **SyncAdapter**, can I “force” the SyncAdapter to update an entity/entity list from the network (and therefore put it into the proper table)? This way, the status flag would be useful.

  4. Can the SyncAdapter work on multiple entities (actually, entity lists, as I want to update books and editors every now and then), since it only has a performSync method?

  5. If my SyncAdapter implementation has been disabled by the user in the device settings it won’t update anything (and that’s fine). But if the user clicks on an “update books” button in an Activity, can I still call the performSync method, or will it be disabled as well?

  • 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-06-11T12:32:41+00:00Added an answer on June 11, 2026 at 12:32 pm

    SyncAdapter is a design pattern involving five components:

    1. An app. This uses a set of Activity along with Cursor and ContentObserver and maybe CursorAdapter and some to provide a UI to the locally stored data from a ContentProvider.
    2. ContentProvider The local device’s data-store. Handles CRUD calls, handles notifying SyncAdapter of the need to push an update to the server.
    3. Account The user identity on the remote server.
    4. SyncAdapter A background process which runs, and keeps the local datastore in sync with the server.
    5. The server itself.

    So. To the questions:

    1. “Is-updating” means, “has local changes which have not yet been pushed to the server. It’s a flag you set on a row in your database. It’s set in ContentProvider when you Create/Update/Delete a row. When SyncAdapter runs, it sees the flag, pushes the update to the server, clears the flag. The flag itself does two things:
      a. Tells the user the app is busy saving the change, and when that’s done.
      b. Marks the row as changed so SyncAdapter knows to push it to the server.
      Read here for more details.

    2. If you’re not syncing the entire catalog, then your client will directly query the server and cache the results by putting them into the ContentProvider. There is no status flag there, since they’re coming from the server and therefore match the server state. Write your SyncAdapter to ignore them, or perhaps discard them after they’ve been cached a few days.

    3. a. To ensure your local updates get sent to the server, you write your ContentProvider to notify the SyncAdapter during the ContentProvider’s Create/Update/Delete calls. (Read here…)
      b. To ensure you get updates from the server periodically, you configure the account for automatic sync. (Read Here…)

    4. Yes. performSync is just a function call. Write it to do what you want. Have it fetch table 1 from the server and put it into one table in your ContentProvider. Then have it fetch table 2, and put it into a different table. Etc.

    5. a. You can force a sync by calling ContentResolver.RequestSync() with ContentResolver.SYNC_EXTRAS_MANUAL in the extras bundle.
      b. You can manually fetch something with client code and directly push it into the ContentProvider.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this question has been asked many times ( but in different
I know that this question has a been asked many times, but I still
I know that this question has been asked many times before in different guises
I know this question has been asked many times, but I never saw a
I know that this question has been asked multiple times already , but I
Hey all, I know that this question has been asked many times in this
I know that this question has been asked loads of times, but I have
I know that this question has been asked several times and I've read all
I know that this sort of question has been asked here before, but still
I know that this question have been asked several times. But I can't get

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.