Print to console db.execSQL on Android

0

How can I get this chain by console? I want to take the console and see if I generate the sentence well. I do not know what parameter to use to load it in the System.out.print

db.execSQL(String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT," +
                    "%s TEXT UNIQUE NOT NULL,%s TEXT UNIQUE NOT NULL,%s INTEGER NOT NULL)",
            Tablas.VALOR, MetadatosDB.Valores.ID_VALOR,
            MetadatosDB.Valores.NOMBRE, MetadatosDB.Valores.CODIGO,
            MetadatosDB.Valores.SITUACION));

System.out.println();
    
asked by Eduardo 16.05.2017 в 10:17
source

1 answer

3

Put the value of the String.format into a variable. So:

String consulta = String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT," +
                "%s TEXT UNIQUE NOT NULL,%s TEXT UNIQUE NOT NULL,%s INTEGER NOT NULL)",
        Tablas.VALOR, MetadatosDB.Valores.ID_VALOR,
        MetadatosDB.Valores.NOMBRE, MetadatosDB.Valores.CODIGO,
        MetadatosDB.Valores.SITUACION);

db.execSQL(consulta);
System.out.println(consulta);
    
answered by 16.05.2017 / 10:22
source