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

  • SEARCH
  • Home
  • 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 7649939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:07:19+00:00 2026-05-31T11:07:19+00:00

I am trying to design how to best handle synchronisation of data between an

  • 0

I am trying to design how to best handle synchronisation of data between an Android application and a remote server through a REST API.

Now it is still early stage but I have my rest server basically running (enough for testing purpose anyway).

I have 3 tables to synchronise (linked as below).

SHOW >—– SEASON >—– EPISODE

Both server and device have a similar version of these tables and I need to synchronise them FROM device to SERVER (for now and eventually 2 ways). The synchronisation will happen through an Android service making asynchronous calls to the REST API (insert/update and delete) in the background.

Now my main issue is coming up with a logic that will ensure both sides will get updated accordingly.

insert/update from device to server will be done through a POST request so I thought of having a state flag on all 3 tables that gets populated via ON INSERT/ON UPDATE TRIGGERS (SQlite) allowing the Synchronisation service to work out rows that need to go on the server. Is that the correct approach ?

It would look something like

CREATE TRIGGER sync_update_show AFTER UPDATE ON show
BEGIN
    UPDATE show SET sync_flag = 'TO_SYNC' WHERE _id = new._id
END

Now for deletion, the service being independent from the main app I though of using BEFORE DELETE SQlite TRIGGERS to populate a “TODELETE” table that the service can browse and trigger delete api calls to the server. Is that the correct approach ?

It would look something like

CREATE TRIGGER sync_delete_show BEFORE DELETE ON show
BEGIN
    INSERT INTO todelete_show
    SELECT * FROM show WHERE _id = old._id
END

Now when it comes to the server to app sync I would just get all records (APi call) and handle the insert/update/delete on the device (browsing through the returned records). But there may be a more efficient approach optimising the bandwidth (the returned JSON might be big).

I welcome any input on that as I do not want to start working on the Service implementation and realise I got it all wrong !

  • 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-31T11:07:20+00:00Added an answer on May 31, 2026 at 11:07 am

    I think your approach using triggers could definitively work, I suggest you use a single “SYNC” table to record all the network operations that you need to make, so that even if you’re offline all network operations are scheduled to be executed when possible, and after you have executed a task delete it from the “SYNC” table.

    I strongly suggest you implement a ContentProvider to store your tables since you can more easily leverage a lot of Android APIs in your activities/fragments, especially the CursorLoaders and CursorAdapters.

    Take a look at contentProviders : http://developer.android.com/guide/topics/providers/content-provider-creating.html

    And also take a look at SyncAdapter:
    http://developer.android.com/reference/android/content/AbstractThreadedSyncAdapter.html

    Also check out this talk about bulding restful apps on android, is a bit old but I think it is still very valid
    http://www.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html

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

Sidebar

Related Questions

I'm trying to find the best way to design my application and precisely my
I am trying to figure out best practice for N-Tier application design. When designing
I'm trying to figure out what's the best design I can go with for
I'm trying to figure out the best way to design Car and Road objects
I'm trying to design a macro to produce several related data structures related to
I'm trying to figure out the best design for the messaging system I'm porting
I'm trying to determine how to best design a storage facility for fast searching
I am trying to determine the best design pattern to use for a business
I'm currently trying to design an application and I'm having trouble trying to decide
I'm trying to design a calendar-type table that is built dynamically based on data

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.