0

I am using the following code to copy the db from assets

public void createDataBase() {
        boolean dbExist = this.checkDataBase();
        if (!dbExist) {
            this.getWritableDatabase();
            **this.close();**
            try {
                this.copyDataBase();
            } catch (IOException var3) {
                var3.printStackTrace();
                throw new Error("Error copying database");
           }
    }

}

In the above code, it was not working in android P if i dint give this.close(). I was unable to create and query the database. But In previous versions it was working fine. I know it is a good practise to close database objects once used. But what is the reason for this behaviour in android Pie?

To get to know this issue in Pie I referred this link but couldn't find the explanation.

Android P - 'SQLite: No Such Table Error' after copying database from assets

Anand Asir
  • 309
  • 3
  • 13

0 Answers0