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.
Related
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.
This question already has answers here:
How to use an existing database with an Android application [duplicate]
(5 answers)
Closed 9 years ago.
I have a sqlite file with an extension of (db_name.sqlite) and i want to reuse this database in my android project instead of creating new one because, this database has huge data stored in it.
How is it possible?
If your "huge data" is less than 50MB, you can package the database as an asset and then unpack it on first run of your app. I recommend SQLiteAssetHelper for this.
Once your APK grows to 50MB, though, things get a bit more complicated, as you would need to either download the database yourself or look into APK Expansion Files.
Once you have the SQLite database in place, you can use it the same way as you use any other SQLite database in Android. SQLiteAssetHelper will offer the same getReadableDatabase() and getWriteableDatabase() methods you see in SQLiteOpenHelper, giving you a SQLiteDatabase object on which you can run queries, etc.
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.
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/
This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
sqlite example program in android
I've created an sqlite3 database and a number of tables using SQLiteManager 3.5.1. However, i've no idea as to how i should be able to connect, access and use the database. Moreover, i also want to be able to modify the tables and the data in the tables. Is it possible to put the database (with the .sqlite extension) within the assets directory and work back and forth from the android to SQLiteManager?
Yes, it's possible. Here it's explained:
Using SQLite from your Android App
Take a look at the Copying from assets to database path section.