use of android.database.sqlite.SQLiteDatabase in project UltimateAndroid by cymcsg.
the class MeetingDAO method findAllByTeam.
public List<Meeting> findAllByTeam(Team team) {
List<Meeting> meetings = new ArrayList<Meeting>();
Cursor cursor = null;
try {
SQLiteDatabase db = getReadableDatabase();
cursor = db.query(MEETINGS_TABLE_NAME, MEETINGS_ALL_COLUMS, MEETINGS_TEAM_NAME + " = ?", new String[] { team.getName() }, null, null, MEETINGS_MEETING_TIME);
while (cursor.moveToNext()) {
meetings.add(createMeetingFromCursorData(cursor));
}
} finally {
closeCursor(cursor);
}
Logger.d("Found " + meetings.size() + " meetings");
Collections.reverse(meetings);
return meetings;
}
use of android.database.sqlite.SQLiteDatabase in project UltimateAndroid by cymcsg.
the class MeetingDAO method findById.
public Meeting findById(Long id) {
Cursor cursor = null;
Meeting meeting = null;
try {
SQLiteDatabase db = getReadableDatabase();
cursor = db.query(MEETINGS_TABLE_NAME, MEETINGS_ALL_COLUMS, _ID + " = ?", new String[] { id.toString() }, null, null, null);
if (cursor.getCount() == 1) {
if (cursor.moveToFirst()) {
meeting = createMeetingFromCursorData(cursor);
}
}
} finally {
closeCursor(cursor);
}
return meeting;
}
use of android.database.sqlite.SQLiteDatabase in project UltimateAndroid by cymcsg.
the class MeetingDAO method delete.
public void delete(Meeting meeting) {
Logger.d("Deleting meeting for " + meeting.getTeam().getName() + " with a date/time of '" + meeting.getDateTime() + "'");
if (meeting.getId() != null) {
SQLiteDatabase db = getWritableDatabase();
db.delete(MEETINGS_TABLE_NAME, _ID + " = ?", new String[] { meeting.getId().toString() });
}
}
use of android.database.sqlite.SQLiteDatabase in project UltimateAndroid by cymcsg.
the class TeamDAO method findByName.
public Team findByName(String name) {
Cursor cursor = null;
Team team = null;
name = name.trim();
try {
SQLiteDatabase db = getReadableDatabase();
cursor = db.query(TEAMS_TABLE_NAME, TEAMS_ALL_COLUMS, TEAMS_NAME + " = ?", new String[] { name }, null, null, null);
if (cursor.getCount() == 1) {
if (cursor.moveToFirst()) {
long id = cursor.getLong(0);
name = cursor.getString(1);
team = new Team(id, name);
}
}
} finally {
closeCursor(cursor);
}
Logger.d((team == null ? "Unsuccessfully" : "Successfully") + " found team with a name of '" + name + "'");
return team;
}
use of android.database.sqlite.SQLiteDatabase in project UltimateAndroid by cymcsg.
the class TeamDAO method findById.
public Team findById(Long id) {
Cursor cursor = null;
Team team = null;
try {
SQLiteDatabase db = getReadableDatabase();
cursor = db.query(TEAMS_TABLE_NAME, TEAMS_ALL_COLUMS, _ID + " = ?", new String[] { id.toString() }, null, null, null);
if (cursor.getCount() == 1) {
if (cursor.moveToFirst()) {
String name = cursor.getString(1);
team = new Team(id, name);
}
}
} finally {
closeCursor(cursor);
}
return team;
}
Aggregations