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