Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void kreiranjeAktivnost(Context context, Aktivnost aktivnost) {
- DataBaseHelper dbHelper = new DataBaseHelper(context);
- SQLiteDatabase sqldb = dbHelper.getWritableDatabase();
- ContentValues entry = new ContentValues();
- {
- entry.put("name", aktivnost.getName());
- entry.put("description", aktivnost.getDescription());
- entry.put("category", aktivnost.getCategory());
- // ...
- Date startTime = aktivnost.getStartTime();
- Date endTime = aktivnost.getEndTime();
- String stringifyStartTime = startTime.getYear() + "/"
- + startTime.getMonth() + "/" + startTime.getDate() + "/"
- + startTime.getHours() + "/" + startTime.getMinutes();
- String stringifyEndTime = endTime.getYear() + "/"
- + endTime.getMonth() + "/" + endTime.getDate() + "/"
- + endTime.getHours() + "/" + endTime.getMinutes();
- entry.put("startTime", stringifyStartTime);
- entry.put("endTime", stringifyEndTime);
- entry.put("adress", "ADRESA");
- String participantsIds = "";
- if (aktivnost.getParticipants() != null
- && aktivnost.getParticipants().size() > 0) {
- for (Ucesnik u : aktivnost.getParticipants()) {
- participantsIds += u.getId() + ",";
- }
- }
- entry.put("participants", participantsIds);
- entry.put("notify", aktivnost.getNotify());
- sqldb.insert("aktivnosti", null, entry);
- Toast.makeText(context, "Activity added", Toast.LENGTH_SHORT)
- .show();
- }
- sqldb.close();
- }
- public static void updateAktivnost(Integer id, Context ctx,
- Aktivnost aktivnost) {
- DataBaseHelper dbHelper = new DataBaseHelper(ctx);
- SQLiteDatabase sqldb = dbHelper.getWritableDatabase();
- // Cursor c = sqldb.rawQuery("select * from aktivnosti where _id="+id,
- // null);
- ContentValues cv = new ContentValues();
- // cv.put("id", c.getInt(0));
- cv.put("name", aktivnost.getName());
- cv.put("description", aktivnost.getDescription());
- cv.put("category", aktivnost.getCategory());
- Date startTime = aktivnost.getStartTime();
- Date endTime = aktivnost.getEndTime();
- String stringifyStartTime = startTime.getYear() + "/"
- + startTime.getMonth() + "/" + startTime.getDate() + "/"
- + startTime.getHours() + "/" + startTime.getMinutes();
- String stringifyEndTime = endTime.getYear() + "/" + endTime.getMonth()
- + "/" + endTime.getDate() + "/" + endTime.getHours() + "/"
- + endTime.getMinutes();
- cv.put("startTime", stringifyStartTime);
- cv.put("endTime", stringifyEndTime);
- String participantsIds = "";
- if (aktivnost.getParticipants() != null
- && aktivnost.getParticipants().size() > 0) {
- for (Ucesnik u : aktivnost.getParticipants()) {
- participantsIds += u.getId() + ",";
- }
- }
- cv.put("participants", participantsIds);
- cv.put("notify", aktivnost.getNotify());
- sqldb.update("aktivnosti", cv, "_id=?",
- new String[] { String.valueOf(id) });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement