mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
implement adding events
This commit is contained in:
@@ -14,6 +14,7 @@ import java.util.List;
|
||||
public class DBHelper extends SQLiteOpenHelper {
|
||||
private static SQLiteDatabase mDb;
|
||||
private static String[] mProjection;
|
||||
private static DBOperationsListener mCallback;
|
||||
|
||||
private static final String DB_NAME = "events.db";
|
||||
private static final int DB_VERSION = 1;
|
||||
@@ -25,7 +26,8 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
private static final String COL_TITLE = "title";
|
||||
private static final String COL_DESCRIPTION = "description";
|
||||
|
||||
public static DBHelper newInstance(Context context) {
|
||||
public static DBHelper newInstance(Context context, DBOperationsListener callback) {
|
||||
mCallback = callback;
|
||||
return new DBHelper(context);
|
||||
}
|
||||
|
||||
@@ -58,6 +60,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
values.put(COL_TITLE, event.getTitle());
|
||||
values.put(COL_DESCRIPTION, event.getDescription());
|
||||
mDb.insert(TABLE_NAME, null, values);
|
||||
mCallback.eventInserted();
|
||||
}
|
||||
|
||||
public List<Event> getEvents(int fromTS, int toTS) {
|
||||
@@ -80,4 +83,8 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
return events;
|
||||
}
|
||||
|
||||
public interface DBOperationsListener {
|
||||
void eventInserted();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user