33

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.

7
  • 1
    You can add your database file in assets folder. Commented May 14, 2012 at 8:29
  • Or you can create the database onCreate with standard sqlite query language Commented May 14, 2012 at 8:30
  • 1
    you can add your db file in the assets folder. If it solution isn't true, should describe your problem. Commented May 14, 2012 at 8:32
  • But how to add in to the asset folder? When I right clicked on the asset item inside the Package Explorer, I couldn't find any option to Add. Is there any other way, please help me. Thanks in advance. Commented May 14, 2012 at 8:34
  • 1
    u need to put ur database(whicch is .sqlite extension) in ur project's asset folder Commented May 14, 2012 at 8:57

1 Answer 1

26

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....

Sign up to request clarification or add additional context in comments.

3 Comments

ok. But physically do I need to keep the empty database file inside the project folder?
thanks for accept see this link vogella.com/articles/AndroidSQLite/article.html
Do we have to create assets folder if not exist?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.