1
I used a populated . sqlite database in a project. I imported the bd into the Assets folder and implemented the code for creating and accessing the database. I ran the project and everything worked ok on emulator and mobile directly. The problem is that when I will generate the signed apk to send to other people the application does not create the bank. The apk is generated normally and the app is also installed on the device, but in Activity that would have to run and query in the database there is an error, which I implemented in the code with a Toast, accusing that it was not possible to create the database. I can not understand why everything works ok when I compile in the emulator or directly on mobile, but when install from the apk does not work part of the bank.
Would anyone have any idea why this should happen?! Thank you!
Note: I cannot see error log because I am generating apk, installing on the device and running. I don’t run the run on Androidstudio, because as I said when the project runs on the emulator or device directly there is no error, but when I install the app from the apk separately on the device, the database does not create. Is there any way to see error logging when the app is installed and run in this separate way from Androidstudio?
The error that gives the Toast "Copy data error" message that states that the database was not created is in this code snippet:
//Check exists database
File database = getApplicationContext().getDatabasePath(DatabaseHelper.DBNAME);
if(false == database.exists()) {
mDBHelper.getReadableDatabase();
//Copy db
if(copyDatabase(this)) {
Toast.makeText(this, "Copy database succes", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Copy data error", Toast.LENGTH_SHORT).show();
return;
}
}
Ask the question the method code
copyDatabase()
.– ramaral
would be the case that Voce take this data and put them in a file ". scv" in the "res/raw" folder for example and create the blank database by the method and then popular it with the data from that file ". csv", something similar happened to me and as the mass of data was relatively small I solved in this way.
– Armando Marques Sobrinho