Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How and where to add sqlite(.db) file in to an android project

Tags:

android

sqlite

I am new to Android. Now, I am trying to work with database. I got many tutorials for manipulating Sqlite database operations. But my doubt is that where should I add the .db file in to the application. In package explorer window of IDE, under which folder group I need to add the .db file? I hope you understand my question.

Thanks in advance.

like image 994
sree_iphonedev Avatar asked May 14 '12 08:05

sree_iphonedev


People also ask

Where do I put db files on Android?

You can add your database file in assets folder. you can add your db file in the assets folder. If it solution isn't true, should describe your problem.

How do I open a .db file on Android?

To open the database inspector select View -> Tool Windows -> Database Inspector from the menu bar of Android Studio. Connect a device running on API level 26 or higher. Run the app. The database schemas appear and you can select the database you want to see.

Where do I put SQLite files?

There is no "standard place" for a sqlite database. The file's location is specified to the library, and may be in your home directory, in the invoking program's folder, or any other place.


1 Answers

If you already have .db file then put that file in assets folder or raw folder

Then you have to copy that file at path /your.package.name/data/data directory for further use.

Otherwise you can create new database using code...

see this example....

like image 94
MAC Avatar answered Sep 28 '22 21:09

MAC