android - Copying preloaded database, adding carriage returns -
i have app comes preloaded database.
my temporary copy function so
private void copydatabase() { assetmanager assetmanager = context.getresources().getassets(); inputstream in = null; outputstream out = null; try { in = assetmanager.open(database_name); out = new fileoutputstream(database_file); byte[] buffer = new byte[1024]; int read; while ((read = in.read(buffer)) > 0){ out.write(buffer, 0, read); } } catch (ioexception e) { log.e("error", e.getmessage()); } { if(in != null) { try { in.close(); }catch (ioexception e) { log.e("error", e.getmessage()); } } if(out != null) { try { out.close(); }catch (ioexception e) { log.e("error", e.getmessage()); } } } } however on android 2.2 keep getting error "database disk image malformed". went ahead , copied off device, onto computer. , sure enough, wouldn't open. did hex compare on 2 files , there 10 instances 1 byte different. hex 0d has been added 10 times in random spots in malformed copy.
copy routine works fine in 3.x+. have developed other apps same method , don't have issue.
any ideas?
not sure issue was, created new sqlite database, imported data, , seemed work.
Comments
Post a Comment