Working on sqlite 3 and Android [duplicate] - android

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.

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 to ship an Android application with a populated database? [duplicate]

This question already has answers here:
Ship an application with a database
(15 answers)
Closed 8 years ago.
i created my first app and I would ship it with a local database that contains about 600 entries.
I tried to hard-code this data in my class but i think it is not a good idea.
So is it possible to copy a database to phone on first start of an application?
Store the file in assests folder or in the xml format in res folder.During start up you can copy to the database.
Rather than hardcoding.You can place that .db file in the assests folder of your application's project.Then by using simple File IO of java.You can copy the file from assests and place it in the respective folder from where you can have access to it in your application.
See this link
It mostly depends on your application type, and the sensitivity of the data, some of the possibilities I can think of:
Adding a raw SQL text file with all the values to your project. Then you check every time in Application.onCreate() if the database exists. If not, you run the import job which runs the SQL on the newly created database.
Same as the first one, but you download the SQL file over https, ensuring that decompiling the application does not leak the information. You need to ensure the user has an internet connection though.
If you prefer using database dumps, you can also import (and export) SQLite dumps. Then you could use the methods described here to set it up in your app. I would not recommend it, because fixing small things is done easier in SQL than in dumps.

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.

PreLoaded data in SQLite for android [duplicate]

This question already has answers here:
Ship an application with a database
(15 answers)
Closed 8 years ago.
I'm new to android application development. I'm on course of developing my first app which displays the time table of the selected class/faculty on the selected day(Mon,Tue etc.,).
I'm all done with UI. Now my problem is how & where to write the code for the entire database insertion (as it should be loaded from the beginning).
Can any one help me with this in a detailed manner as i'm new to this field ?
The general steps for what you are looking to do are as follows:
1) Create/convert your database to SQLite (the db used by Android)
2) Put the database in your assests folder
3) Write code to copy the DB from your assets folder to the private databases folder for your app when it runs for the first time.
4) Write code to access the database as necessary once the DB is in the private folder.
A tutorial for using/importing an existing SQLite database in your app can be found at http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
There are many tutorials for creating a database helper class (to handle Creation, Reading, Updating and Deleting functions). A good one I've used and recommended before can be found at http://www.anotherandroidblog.com/2010/08/04/android-database-tutorial/
I think what you need is to ship your database with your apk. You, however, will need to move the database file, because the system expects its databases to be in the private storage. You can see how this is done here.
If it so happens that your database file is big (more than 1MB) combine with this answer in order to achieve the shipment.

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