What is the best strategy to do data synchrony offline/online?

Asked

Viewed 397 times

1

I’m about to get an app for external sales, it will basically carry out orders and if you don’t have an internet connection, it will sync when you do. Good..

How to make this app professional?

Example: Use of services, broadcastReceivers, webservice, this I have in mind to use, someone can help me what an application has to be considered good, professional?

  • Hello @brunoh. Welcome to [en.so]. Your question is very broad and the answers would probably be based on opinions, which runs away from the model of this community. I recommend a visit to [help] mainly in the [Ask] section. You can then [Dit] it so that other Pos can help you.

1 answer

0

Some points to consider:

  1. To allow offline operation (external sales) your application must contain all products in a local database (example: in Sqlite)
  2. You need to sync whenever possible, depending on the frequency of change of these products...if these are updated monthly, then you can use a Alarmmanager to do this periodic update, considering cases, for example if the phone is off at the time of 'Trigger', when connecting the device do the check and 'update' if there is connection.
  3. You can also start from a strategy in which you only sync when the device is connected on Wifi, you can check the types of connection with the Connectivitymanager
  4. To download the data, you choose the format, whether it is in a JSON service or a batch of data in zip. The choice will not fail to be less or more professional.
  5. I believe that you will need to upload the orders made while offline, then you will certainly need a webservice available on the server to receive this data. From this requirement, a running webserver is required to receive this data and process it.

The use of Broadcastreceivers it will be necessary in the detection of connection type change for example, already the Service it will be necessary at the time of processing the information as 'download' of the server data and 'upload' of the data to the server.

  • 1

    For data synchronization, it is worth searching about SyncAdapter and ContentProvider, I always hear about them when that’s the point. As for the application to be considered good/professional, you should clarify in the question whether it refers to the user experience with the application (when it should be considered points such as UX, usability, etc.) or only to the choice of technologies to develop it (example: avoid the use of Polling, adopt the subclass of ViewGroup more suitable for each type of screen layout, etc).

  • 1

    I really liked the answer Alécio Carvalho, I was not running away from my strategy that was in mind..

  • About using sysncAdapter, and an interface that when implemented in our class, can you use the doBackground method? That for me it’s like spinning on a thread, I must be wrong, but I’ve only seen it once and I have this thought of it, I’ll study more about it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.