Open main menu

CDOT Wiki β

Changes

MAP524/DPS924 Lecture 6

461 bytes added, 14:56, 4 August 2015
Using a pre-built DB file
catch (IOException e) { e.printStackTrace(); }
dbOpenHelper = new DatabaseOpenHelper(context); /** * This function comes from the database example in the book. I've no idea * why it's necessary, does Android really not have a function that does this? */public void copyFile(InputStream inputStream, OutputStream outputStream) throws IOException{ byte[] buffer = new byte[1024]; int length; while ((length = inputStream.read(buffer)) > 0) outputStream.write(buffer, 0, length); inputStream.close(); outputStream.close();}</source>
Make sure this code runs when your app starts up and don't forget to put your db file in the assets folder.