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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:13:18+00:00 2026-06-03T10:13:18+00:00

I have an android app that maintains a local SQLite database of different geographic

  • 0

I have an android app that maintains a local SQLite database of different geographic locations.

Now I would like to connect that database to the “cloud” to accomplish the following:

  • an initial download of everything, when the app is first installed (or on request)

  • new locations that have been added locally should be uploaded to the cloud (automatically)

  • the online database should be checked occasionally for new online entries, and downloaded to the local database.

I have a number of problems in accomplishing this.

The first is simply how to do it. I think it involves contentProviders and syncProviders, but I’m not exactly sure how. Do I need to duplicate my SQLite database in a contentProvider, or have I made a mistake in the underlying design to use a database directly, instead of through a custom content Provider?

Secondly, the location records cannot simply be copied up and down from the online database, since they will have conflicting ID numbers. I have several relational tables, such as “tags” which relate a tag-id to a location-id. My tag-ids will not necessarily match another users tag-ids. Same with location ids. So there will need to be some logic involved in the transfer. Where / how should this be properly handled? Is that the role of a contentResolver? (not sure what that is really)

Thirdly, what happens in the case where 2 users add the same location at the same time (perhaps with differing descriptions and details)? Is there a best-practice for merging these records?

Finally, what is the simplest way to build / host the online component? This part is all new to me. Can I just put the master database in a public dropbox folder, or do I need to build a custom php web-app from scratch? Or is there a pre-packaged solution that would make this part easier?

  • 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-03T10:13:20+00:00Added an answer on June 3, 2026 at 10:13 am

    You should definitely use ContentProvider and SyncAdapters. You should:

    • Wrap your database functionality with the ContentProvider interface
    • Setup a SyncService matching the authority of the ContentProvider
    • In your SyncAdapter specialization, you will override onPerformSync()
    • Use SharedPreferences storage to keep track of your sync parameters e.g. lastSync time, etc.

      final SharedPreferences syncMeta =
                          mContext.getSharedPreferences("sync:" + account.name, 0);
      long lastSyncTime = syncMeta.getLong(LAST_SYNC, 0);
      long lastServerSyncTime = syncMeta.getLong(SERVER_LAST_SYNC, 0);
      
    • This can easily tell you if its the first sync and you can do the initial handling here

    • You will write your algorithm here for sync i.e one way/two way.
    • I find it useful to record timestamps and server database ID in your Android records to help with sync. This can help you with your merge strategy.
    • Use the ContentProvider here for DB operations. ContentProviders provide a uniform way of accessing your data from your app as well as sync adapters. They will notify the system of updates so that the framework and schedule sync. They can also be helpful as public interfaces of your data to other apps should you choose to do so.

    • Also, by using SyncService you are saving battery. The system will use network tickles to kick of sync operations and its best if they are batched together for all apps instead of each app waking up the system

    Finally,

    There are two samples you should look at. They pretty much cover everything I explained

    1. JumpNote – http://code.google.com/p/jumpnote/source/browse/
    2. SampleSyncAdapter – http://developer.android.com/resources/samples/SampleSyncAdapter/index.html

    Both these apps use Google App Engine for the cloud component. Its easy to get started with, so definitely explore that options.

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

Sidebar

Related Questions

I have an Android app that I would like to convert to an Android
I have an android app that is using a SQLite database to determine if
I'm writing an Android app and I have a class that generates and maintains
I have android app that talks to server and syncs some data int SQLite
I have an android app that needs to connect frequently to the server to
I have an Android app that I had working a few months ago which
I have an Android app that begins by displaying a dialog. When I set
I have an Android app project that contains all of my code. I've made
I started developing an android app that have to interact with MMS attachements, in
I have a dialog in an Android app that I don't want the user

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.