I have two separate projects, a plus and free version. Both projects use a considerable amount of shared code, so I am attempting to integrate everything that is shared into a Android Library Project.
One of the shared resources is a database that I had 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 was moving 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 an AssetManager for the library project? Or is there another way that I could/should be doing this?