Commit | Line | Data |
---|---|---|
bdd8f09c PT |
1 | package ro.ieval.unical; |
2 | ||
819197b2 | 3 | import android.content.ContentValues; |
bdd8f09c PT |
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; | |
819197b2 PT |
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 | }; | |
bdd8f09c PT |
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 | ||
819197b2 PT |
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 | } | |
bdd8f09c PT |
42 | //Delete event |
43 | //Search event | |
44 | } |