-
Notifications
You must be signed in to change notification settings - Fork 0
/
DBHelper.java
38 lines (33 loc) · 1.09 KB
/
DBHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package br.com.home.adaptercustomizado;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by allanromanato on 6/2/15.
*/
public class DBHelper extends SQLiteOpenHelper {
static final String BANCO = "carro.db";
static final int VERSAO = 1;
static final String TABELA = "carros";
static final String ID = "_id";
static final String FOTO = "foto";
static final String NOME = "nome";
static final String DONO = "autor";
public DBHelper(Context context){
super(context, BANCO, null, VERSAO);
}
@Override
public void onCreate(SQLiteDatabase db) {
String sql = "create table " + TABELA
+ "(" + ID + " integer primary key autoincrement, "
+ NOME + " text, "
+ DONO + " text, "
+ FOTO + " blob )";
db.execSQL(sql);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("drop table if exists " + TABELA);
onCreate(db);
}
}