]> iEval git - unical.git/blobdiff - src/ro/ieval/unical/MySQLiteHelper.java
First real commit
[unical.git] / src / ro / ieval / unical / MySQLiteHelper.java
diff --git a/src/ro/ieval/unical/MySQLiteHelper.java b/src/ro/ieval/unical/MySQLiteHelper.java
new file mode 100644 (file)
index 0000000..889ebda
--- /dev/null
@@ -0,0 +1,58 @@
+package ro.ieval.unical;
+
+import java.sql.SQLClientInfoException;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteDatabase.CursorFactory;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.util.Log;
+
+public class MySQLiteHelper extends SQLiteOpenHelper {
+       public static final String Name="Events";
+       
+       public static final String ID = "_id";
+       public static final String name = "Name";
+       public static final String description = "Description";
+       public static final String date = "Date";
+       public static final String time = "Time";
+       public static final String repeat = "repeat";
+       public static final String repeatIn = "repeatInterval";
+       public static final String location = "Location";
+       
+       private static final int dbversion=1;
+       
+       private static final String Database_create = "create table " + Name + "(" + 
+                       ID + " integer primary key autoincrement, " +
+                       name + " text not null, " + 
+                       description + " text, " + 
+                       date + " integer, " + 
+                       time + " integer, " +
+                       repeat + " integer, "+
+                       repeatIn + " integer, " +
+                       location + " text);"
+                       ;
+       
+       public MySQLiteHelper(Context context) {
+               super(context,Name, null, dbversion);
+               // TODO Auto-generated constructor stub
+       }
+
+       @Override
+       public void onCreate(SQLiteDatabase db) {
+               // TODO Auto-generated method stub
+               db.execSQL(Database_create);
+               
+       }
+
+       @Override
+       public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+               // TODO Auto-generated method stub
+               Log.w(MySQLiteHelper.class.getName(),
+                       "Upgrading database from version " + oldVersion + " to "
+                           + newVersion + ", which will destroy all old data");
+                   db.execSQL("DROP TABLE IF EXISTS " + Name);
+                   onCreate(db);
+       }
+       
+}
\ No newline at end of file
This page took 0.02614 seconds and 4 git commands to generate.