I have two separate projects, plus and a free version. Both projects use a significant amount of common code, so I'm trying to integrate everything that is shared into an Android library project.
One of the common resources is the database in which I was sitting in FreeProject / assests / database.db. This file is shared between both projects, and I would like to move it to LibraryProject / assets / database.db.
In the code, I moved the database to the database folder with the following:
String dbLocation = "/data/data/" + myContext.getPackageName() + "/databases/" + DBNAME; //Reading the asset and writing it to the database folder. InputStream myInput = myContext.getAssets().open("database.db"); OutputStream myOutput = new FileOutputStream(dbLocation); byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer)) > 0) { myOutput.write(buffer, 0, length); } myOutput.flush(); myOutput.close(); myInput.close();
So my question is: how can I call getAssets () to get the AssetManager for the library project? Or is there another way I could / should have done this?
source share