I am a novice, and am creating a simple app that just reads data from a table in an SQLite database and displays on the GUI. (Just select operation )
During development, I created the database and the table from the tool “SQLite Database browser”. And I inserted all data into the table through the tool.
Now, my doubt is ..
1) In java code, should I have some method that creates database and table ?? (For now, I have methods to do the select operation alone)
2) The database I created is located in my local drive. When the apk file gets created would the database also be included in the apk file ??
Pls help !! Thanks in advance !!
No, You have to just copy your database file from
/assetdirectory to/data/data/<package_name>/databasedirectory. And only use select operation alone. You don’t need to use create Database and table operation..For this, as I mentioned above you have to first put your database file into application’s
/assetdirectory, then copy it to internal storage (when your application start), then it works.Look at this SO question How to ship an Android application with a database?. It answered what you needed.