Android Question any idea about working on the offline database and then synchronizing it when connected to the internet through the application ؟

AlfaizDev

Well-Known Member
Licensed User
any idea about working on the offline database and then synchronizing it when connected to the internet through the application ؟
If we assume that the rule is on the mysql server and a local rule is made sqlite for offline mode, how can they be fully synchronized in a moment, is there any idea about this?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The only reliable solution is to log ALL RECORDS when changed when an edit is made then update the record. Then, when syncing, if the LOGGED record doesn't match the record you are updating a human being has to look at ALL LOGGED changes since to both records AND look at the original record and decide what to do.
This is more or less how CloudKVS works. Everything is added to a local journal that is synchronized when internet is available.
 
Upvote 0

AlfaizDev

Well-Known Member
Licensed User
There is no clean way to do it short of keeping a log of all changes "AND WHAT WAS DONE". Then combining the logs and processing them in sequential order and somehow having the log know what was done. What if someone updates information based on old data. Example: customer calls the sales guy and says "Add 10 more to my order" so the sales guy updates the order from 10 to 20. Later he wants to add another 10 but he can't reach the salesman so he calls the office and says, "Add another 10 to my order." So the office updates the order from 10 to 20 because they don't know about the 10 the salesman added. At this point the order should be 30 but the last edit was 20. Dates can have a similar problem. Even text fields if edited by two people would only result in the last edit if working solely by time. And that is only TWO users. What happens when a THIRD user updates the record. And user 3 updates the record between user 1 and user 2 but user 3 gets back to the office and updates his data first?

The only reliable solution is to log ALL RECORDS when changed when an edit is made then update the record. Then, when syncing, if the LOGGED record doesn't match the record you are updating a human being has to look at ALL LOGGED changes since to both records AND look at the original record and decide what to do.

How do I know this? I wrote a "simple" app for myself to store information across my multiple devices. No other users involved. What a mess!​
Thank you all
I think this makes sense
This means that with any user connected to the internet
We need to do a general comparison to prevent conflicts or the first inputs being lost
Is this it?
 
Upvote 0

AlfaizDev

Well-Known Member
Licensed User
This is more or less how CloudKVS works. Everything is added to a local journal that is synchronized when internet is available.
I did not understand well how CloudKVS works
Does it need a b4j intermediary program to synchronize or what
On vps hosting
 
Upvote 0
Top