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

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.

Related

How to fill SQLite database in android? [duplicate]

This question already has answers here:
Ship an application with a database
(15 answers)
Closed 7 years ago.
I wanna develop an application which has a database which is filled with data. How should I fill the database with data? which of the following should I do?
1- Write a little android app and fill the database and somehow get access to the database file and put that in the app. (I think this is bad)
2- Use some kind of sqlite software to fill the database file and then access the database file and put that in the app.(Again I think this is bad)
3-Any other method.
If the data is not huge, you can download the data from server and fill sqlite database when the user first starts the app.
If the data is huge, you can store the data in a file and put under /res/raw folder of the apk and write code to copy those data to sqlite when the app starts for first time.

How can we reuse a Sqlite file in Android which is already created in IOS [duplicate]

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.

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

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

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.

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