0
package com.example.wesley.bancodedadossqlite;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by Wesley on 17/01/2018.
*/
public class CriaBanco extends SQLiteOpenHelper {
private static final String NOME_BANCO = "banco.db";
private static final String TABELA = "livros";
private static final String ID = "_id";
private static final String TITULO = "titulo";
private static final String AUTOR = "autor";
private static final String EDITORA = "editora";
private static final int VERSAO = 1;
@Override
public void onCreate(SQLiteDatabase db) {
String sql = "CREATE TABLE " + TABELA + "("
+ ID + "integer primary key autoincrement,"
+ TITULO + "text,"
+ AUTOR + "text,"
+ EDITORA + "text"
+")";
db.execSQL(sql);
}
@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
db.execSQL("DROP TABLE IF EXISTS" + TABELA);
onCreate(db);
}
}
the
EXISTS
cannot be pasted to the table name. Start by separating"DROP TABLE IF EXISTS " + TABELA
– Isac
was that msm. Thank you!
– use3265498465