Opening a database in Sqlite instead of creating in Android Studio

Asked

Viewed 548 times

1

Hello, I would like your help if there is a possibility to open a database. db (instead of creating the file) by android studio using sqlite.

I’ve already created a data file. db with the data and played inside the device folder (date/date...etc), the database will only serve for query, I imagine it is in the Oncreate method of the Sqliteopenhelper class that can open the database, but I have no idea how.

  • 1

    Voce needs to create the way to open dabases from your sqlite helper normally, well, if the helper is creating db, it will create in the folder /data/user/0/com.seodominio.suaapp/Databases, then simply Browse the file you have in this folder with the file you created and voilá, remembering that it should be the same as the one you create in the helper, because the methods will have to search them through their columns and etc.

  • So this is the procedure that I did, it creates the database, but I wanted to know if there is any method that I can open it referencing it in some directory, instead of creating and overlapping.

  • I was floating in this... you create and/or open the db with sqlitehelper methods, if you want to handle this file you would have to have a tool for it installed on the device or fill it with the data q vc needs when it is created using a csv file or any other in the res/raw folder or app/Assets

  • I answered that question which may be what you want https://answall.com/questions/234894/loading-um-banco-sqlite-criado-externalit/234960#234960

1 answer

0

Natively there is no way to send a populated . db file. I have also searched it. You have some options:

1) Use a library that does this (I found some, but never used)

2) Create the required Inserts during the creation of the bank, if that’s not too much.

3) Download data from a server over the internet at the first application run and populate the database.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.