packagecom.example.wesley.bancodedadossqlite;importandroid.database.sqlite.SQLiteDatabase;importandroid.database.sqlite.SQLiteOpenHelper;/***CreatedbyWesleyon17/01/2018.*/publicclassCriaBancoextendsSQLiteOpenHelper{privatestaticfinalStringNOME_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);
}
}