Open main menu

CDOT Wiki β

Changes

MAP524/DPS924 Lecture 6

18 bytes added, 17:53, 18 July 2015
Using a pre-built DB file
If you want your app to come with some pre-built data in the database then it's probably easiest to follow the example above to create the file, add it to your resources, and copy it into the correct place the first time your app starts. For example:
<presource lang="java">try
{
String destPath = "/data/data/" + context.getPackageName() + "/databases/";
catch (IOException e) { e.printStackTrace(); }
dbOpenHelper = new DatabaseOpenHelper(context);</presource>
Make sure this code runs when your app starts up and don't forget to put your db file in the assets folder.