I have been following a tutorial on how to copy a preloaded SQLite database into my android app, however it never does.
I have been through the debugger and when it gets passed
OutputStream myOutput = new FileOutputStream(outFileName);
it just stops it doesn't go to the next line.
Code:
InputStream myInput = myContext.getAssets().open(DB_NAME);
String outFileName = DB_PATH + DB_NAME;
OutputStream myOutput = new FileOutputStream(outFileName);
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))>0){
myOutput.write(buffer, 0, length);
}
myOutput.flush();
myOutput.close();
myInput.close();
Path:
private static String DB_PATH = "/data/data/Application/databases/";
private SQLiteDatabase database;
private final Context myContext;
private static String DB_NAME = "quizDB.db",
I have used the correct path and the correct name of my .db file
Anyone know why and how to fix it?
Aucun commentaire:
Enregistrer un commentaire