Do changes in SQLite automatically get reflected in MySQL? [duplicate] - android

This question already has answers here:
How to sync SQLite database on Android phone with MySQL database on server?
(5 answers)
Closed 9 years ago.
I am new to using services. In my application I want to run services in the background. I am creating the same database in MySQL server and SQLite. If I change some data in a table in the SQLite database, does it mean it should automatically store the change in the MySQL-server also?

To answer your question: no, it does not automatically reflect the changes made in SQLite into MySQL.
Why? Because you basically have 2 different databases, although they have the same name (and probably structure). In order for them to communicate and get synchronized, you need to implement some kind of communicating mechanism.
As suggested to you by eggyal in an above comment, take a look here, as a solution for this kind of problem is explained there.

Related

syncing SQL and SQlite database [duplicate]

This question already has answers here:
Synchronizing client-server databases
(6 answers)
Closed 6 years ago.
I have a SQL database and I would like to be able to copy to/sync with an SQLite in my android app so that people are able to query data without needing an internet connection. I wasnt sure how i would go about updating the SQLite database if fields or tables are altered in the SQL database.
What would be the best way about going about this, I have only ever used the databases separately and this is my first time doing this.
I recommend putting in a version table and use sql scripts to update the schemas.
You'd need one script for the SQL server and one for SQLite.
Then you can find all the scripts beyond the first on the android device ... and then run each script in turn.
I've done this before when I was looking after a few hundred remote desktop clients.
The main trick is making the SQL scripts work for the first run and if need be for a subsequent run.

Android and sqlite, can I populate a database before upload? [duplicate]

This question already has answers here:
Ship an application with a database
(15 answers)
Closed 8 years ago.
I have an app that just need to read from a database. I do not want to parse a big file in the app because it takes a lot of memory.
So is it possible to populate a database and ship it with the app?
Just parsing the file and storing it in the app the first time the app is run will not do since it will create the same memory problem.
An alternative would be to have the database on Google Appengine but I would like to avoid that because the app would be unusable if there is no internet connection and there are costs for the traffic.
So is it possible to populate a database and ship it with the app?
Yes. Create a SQLite database containing your data, then package it with your app using SQLiteAssetHelper. It will be unpacked into position when you first try to use the database.

Two database in one app [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Multiple database in single app in android
I have one app with it's database file. Now i want to build another database file in this app to store another kind of data. Is it posible?
Though it is possible to have multiple database in single app, still I will suggest to have multiple tables in single database instead of multiple database.
Here is a solution to create multiple database.
How to add multiple database in single app

android using sqlite as a static data [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Android pre-filled DB
I want to use SQLite as a static data. By that I mean to preload it with data before application first start. This data is static = no inserts, deletes or updates. I just want to use full power of sql database queries and indexes. Because my SQLite database should have a lot a lot of data I don't want to upset users with long initial loading time.
Is there any way to do it (preloaded, predefined, preinserted database)?
No, sadly this is not possible. A workaround is to copy the database over to the application data or to the SD card (if available) and load it from there, but IMHO this is an ugly solution.
Have you thought about using Java data structures for this data? It should be much faster to preload. If you do not want to use plain Java structures, I would recommend to use JSON or protobuf - whatever works best for you. :-)

Where do you place the starting SQLite database within an Android project? [duplicate]

This question already has answers here:
Ship an application with a database
(15 answers)
Closed 8 years ago.
I have seen many solutions which are code oriented, like if you have to create a table, you would have to create it using code, but this is not good for complex applications, as we have SQLite Browser to create database and its tables, and it generates a database file.
Now the question is, where to place that file in my project, there is no data folder in eclipse project, I dont know what to do, its interaction is not like MySQL where we use driver or connection?
You can follow this steps to use an existing database in your application:
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
I've also made a blog post some time ago which combined the solution above with the use of ormlite:
http://www.b-fil.com/blog/2011/01/20/android-repository-ormlite-existing-sqlite-db/

Categories

Resources