· 9 years ago · Nov 11, 2016, 12:14 AM
1import android.content.Context;
2import android.database.sqlite.SQLiteDatabase;
3import android.database.sqlite.SQLiteOpenHelper;
4
5/**
6 * Created by L00960401 on 11/10/16.
7 */
8
9public class NoteHelper extends SQLiteOpenHelper {
10
11 public static final String NOTAS_TABLA = "notas_tabla";
12 public static final String COLUMNA_ID = "_id";
13 public static final String COLUMNA_NOTA = "nota";
14 public static final String[] columnas = { COLUMNA_ID, COLUMNA_NOTA };
15
16 private static final String NOMBRE_BD= "notas.db";
17 private static final int VERSION= 1;
18
19 private static final String CREACION = "create table " +
20 NOTAS_TABLA + "(" +COLUMNA_ID + " integer primary key autoincrement, " +
21 COLUMNA_NOTA + " text not null);";
22
23
24 public NoteHelper(Context context) {
25
26 super(context, NOMBRE_BD, null, VERSION);
27
28 }
29
30 @Override
31 public void onCreate(SQLiteDatabase db) {
32
33 db.execSQL(CREACION);
34
35 }
36
37 @Override
38 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
39
40 db.execSQL( "DROP table IF Exists " + NOTAS_TABLA);
41 onCreate(db);
42 }
43}