]>
Commit | Line | Data |
---|---|---|
bdd8f09c PT |
1 | package ro.ieval.unical; |
2 | ||
bdd8f09c PT |
3 | import android.content.Context; |
4 | import android.database.sqlite.SQLiteDatabase; | |
bdd8f09c PT |
5 | import android.database.sqlite.SQLiteOpenHelper; |
6 | import android.util.Log; | |
7 | ||
8 | public class MySQLiteHelper extends SQLiteOpenHelper { | |
9 | public static final String Name="Events"; | |
10 | ||
11 | public static final String ID = "_id"; | |
819197b2 | 12 | public static final String title = "Title"; |
bdd8f09c PT |
13 | public static final String description = "Description"; |
14 | public static final String date = "Date"; | |
819197b2 | 15 | public static final String duration = "Duration"; |
bdd8f09c PT |
16 | public static final String repeat = "repeat"; |
17 | public static final String repeatIn = "repeatInterval"; | |
18 | public static final String location = "Location"; | |
19 | ||
20 | private static final int dbversion=1; | |
21 | ||
22 | private static final String Database_create = "create table " + Name + "(" + | |
7be52756 PT |
23 | //ID + " integer primary key autoincrement, " + |
24 | ID + " text primary key, " + | |
819197b2 | 25 | title + " text not null, " + |
bdd8f09c PT |
26 | description + " text, " + |
27 | date + " integer, " + | |
819197b2 | 28 | duration + " integer, " + |
bdd8f09c PT |
29 | repeat + " integer, "+ |
30 | repeatIn + " integer, " + | |
31 | location + " text);" | |
32 | ; | |
33 | ||
34 | public MySQLiteHelper(Context context) { | |
35 | super(context,Name, null, dbversion); | |
36 | // TODO Auto-generated constructor stub | |
37 | } | |
38 | ||
39 | @Override | |
40 | public void onCreate(SQLiteDatabase db) { | |
41 | // TODO Auto-generated method stub | |
42 | db.execSQL(Database_create); | |
43 | ||
44 | } | |
45 | ||
46 | @Override | |
47 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |
48 | // TODO Auto-generated method stub | |
49 | Log.w(MySQLiteHelper.class.getName(), | |
50 | "Upgrading database from version " + oldVersion + " to " | |
51 | + newVersion + ", which will destroy all old data"); | |
52 | db.execSQL("DROP TABLE IF EXISTS " + Name); | |
53 | onCreate(db); | |
54 | } | |
55 | ||
56 | } |