Add function to add event into local database
[unical.git] / src / ro / ieval / unical / DatabaseInteract.java
1 package ro.ieval.unical;
2
3 import android.content.ContentValues;
4 import android.content.Context;
5 import android.database.SQLException;
6 import android.database.sqlite.SQLiteDatabase;
7
8 public class DatabaseInteract {
9 private SQLiteDatabase database;
10 private MySQLiteHelper dbHelper;
11 private String[] allColumns = {
12 MySQLiteHelper.ID, MySQLiteHelper.title,
13 MySQLiteHelper.description, MySQLiteHelper.date,
14 MySQLiteHelper.duration, MySQLiteHelper.repeat,
15 MySQLiteHelper.repeatIn, MySQLiteHelper.location
16 };
17
18 public DatabaseInteract(Context context) {
19 dbHelper = new MySQLiteHelper(context);
20 }
21
22 public void open() throws SQLException {
23 database=dbHelper.getWritableDatabase();
24 }
25
26 public void close() {
27 dbHelper.close();
28 }
29
30 //Insert event
31 public void insertEvent(Event e) {
32 ContentValues values = new ContentValues();
33 values.put(allColumns[1],e.title);
34 values.put(allColumns[2],e.description);
35 values.put(allColumns[3],e.date);
36 values.put(allColumns[4],e.duration);
37 values.put(allColumns[5], e.repeat);
38 values.put(allColumns[6], e.repeatInterval);
39 values.put(allColumns[7], e.location);
40 database.insert(MySQLiteHelper.Name, null, values);
41 }
42 //Delete event
43 //Search event
44 }
This page took 0.021199 seconds and 4 git commands to generate.