I want to sync data between android SQLite database and MySQL database offline/online from multiple users???
I have two tables
- For User details
- For their queries
I tried by saving data to SQLite first and then send it to the server but there is data confliction. how can I manage unique id to that particular table matched with the SQLite database? Suppose,
- I have inserted a query from User A. it is saved in SQLite DB and sent to the server after being online. so primary key id is 1 and is the same for MySQL & SQLite.
- Now User B also submits his query. it is also saved in SQLite DB and sent to the server. so here is also primary key id is 1. Now it will give error as it is going against the primary key as it is the same id as already stored in the server.
So, now how can I avoid data confliction. Remember I am creating an app for offline and online both. when the internet is not available, it will be saved to SQLite and after being online it will be saved to MySQL server.
Any suggestion or any way would be appreciable.