Table is not created after running the query

I have a problem to create a table. What is happening is the following, I have an xml file which is what I want the queries that are executed when I change the version of the database. The problem is that it reaches a height of processing the query is executed but the change in the database is not taken, the strange thing is that in my xml file has two different queries, the first runs but not the second and the worst is that it is not pointed any bank error, my script is correct and is returning all queries but it happens and I do not know why. Below is my function responsible for executing the queries of my xml:

private boolean execSqlByQuery(List<String[]> listaQuery, SQLiteDatabase db) {
    Boolean result = false;
    if(!listaQuery.isEmpty()){
        try{
            for(int i = 0; i < listaQuery.size(); i++){
                for(int j = 0; j < listaQuery.get(i).length; j++){
                    db.beginTransaction();
                    Log.d("SQL", listaQuery.get(i)[j].toString());
                    db.execSQL(listaQuery.get(i)[j].toString());
                    db.setTransactionSuccessful();
                    db.endTransaction();
                }
            }
            result = true;
        }catch(Exception ex){
            result = false;
        }finally{
            listaQuery.clear();
        }
    }
    return result;
}

Answers


Change your code like:

private boolean execSqlByQuery(List<String[]> listaQuery, SQLiteDatabase db) {
Boolean result = false;
if(!listaQuery.isEmpty()){
db.beginTransaction();
    try{
        for(int i = 0; i < listaQuery.size(); i++){
            for(int j = 0; j < listaQuery.get(i).length; j++){

                Log.d("SQL", listaQuery.get(i)[j].toString());
                db.execSQL(listaQuery.get(i)[j].toString());


            }
        }
 db.setTransactionSuccessful();
        result = true;
    }catch(Exception ex){
        result = false;
    }finally{
if (db!= null) {
 db.endTransaction();
}
        listaQuery.clear();
    }
}
return result;
}

Need Your Help

How to measure the speed of an Arduino function's execution?

c++ time arduino measurement stopwatch

I need to determine the speed with which Arduino executes a certain function.

Div updating with image dynamically..... JSF

java jsf jstl

How to replace an image in DIV dynamically on click of some other div image as shown in image.