Android Question DB sincronyze

powerino

Active Member
Licensed User
Hi everyone, I have a technical and perhaps "stupid" question:
I created a DB with SQLite and I am using it in my app (still under development) and I saw that the data present in the App's DB is not in the physical DB on the PC. How can I copy / synchronize the App DB data to the PC DB?

Thank you
 

Albert Kallal

Active Member
Licensed User
Well, this might be easy problem, or a big problem.

It not clear if you just looking to "copy back" the db to your dev computer, or you talking about a actual data sync.

During development, you often are still adding columns, tweaking the database etc. So, you likly just include the sqlite db as part of your project.

If you enter some data android side? Well, then you could connect (usb) and then say copy the db back to your pc. Or say have the db reside on a SD card, and use the old "sneaker" or "foot ware" network idea (you manully pull the sd card from the phone, and plug it into your computer - and copy the db back to the computer and now you have a copy on your computer.

However, a data sync between your computer and the phone? That is a big ball of wax - a far more reaching and complex problem. Perhaps you don't need a bi-directional sync. (just to pull data from the android.
Again, simple super low cost: on android side, crank out a cvs file - email to your computer - import the csv file.

However, if you want a both ways sync? Well now you need to choose some type of connection and "system" to connect to.

So is the goal a data transfer (a file) or an actual sync of data. And on your desktop/computer side, where is the data to land?
You could use one of several "bridge" examples in which you run some software on a server (or your workstation). This would then allow you to connect and talk to that computer using jDBC. However, is this just your device, or are say 15 employees to use this application? That being the case, then you talking about some form of web hosting here. Or at least having some server or computer running something that the phone can connect to.

I am right now as I am typing this writing a sync routine from sqlite android to my desktop running SQL server. And I cooked up a nice bit of code that will sync, and do so with minimal code (the trick I am using is I set the sqlIte database to start all auto numbers at 100,000. When I sync, I get the PK's back from the server, and sqlite will cascade update the child tables. It is a simple system - but that's because I am keeping this simple. Thus, after a sync, the PK's on both sides match. And the sync code is simply based on a date stamp - so it not at all much code. (I had hoped that I could set the PK's in sqlite to start at -1, -2, -3, and thus you never get collusions. When you sync, you grab/get the new PK's from the server. This trick makes data sync VERY easy. However, thankfully sqlite does allow one to set the PK starting numbers - so I just start at 100,000 and again PK issues are gone.

So, you might be able to cobble together a bit of code - it really depends on the breath and scope and the kind of data sync you are looking for. This topic can be as large as going to university and obtaining a medical degree. It is a HUGE topic, and you have to nail down what you need. Again a HUGE topic.

So do you need transportation like say a bicycle, or are you talking about a military grade turbine powered helicopter. After all, they are both forms of transportation - but the complexly of running that turbine helicopter is significantly more then jumping on your bicycle.

So, you have to elaborate on you goal here - just a transfer of the whole db as a file, or are we talking about some kind of sync of data?
Regards,
Albert D. Kalla
Edmonton, Alberta, Canada
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…