Search in sources :

Example 16 with SQLiteDatabase

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;
}
Also used : Meeting(com.marshalchen.common.uimodule.standuptimer.model.Meeting) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 17 with SQLiteDatabase

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;
}
Also used : Meeting(com.marshalchen.common.uimodule.standuptimer.model.Meeting) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 18 with SQLiteDatabase

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() });
    }
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 19 with SQLiteDatabase

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;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Team(com.marshalchen.common.uimodule.standuptimer.model.Team) Cursor(android.database.Cursor)

Example 20 with SQLiteDatabase

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;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Team(com.marshalchen.common.uimodule.standuptimer.model.Team) Cursor(android.database.Cursor)

Aggregations

SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1553 Cursor (android.database.Cursor)499 ContentValues (android.content.ContentValues)321 ArrayList (java.util.ArrayList)105 File (java.io.File)65 Test (org.junit.Test)57 SQLiteException (android.database.sqlite.SQLiteException)45 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)44 Uri (android.net.Uri)44 ServiceStatus (com.vodafone360.people.service.ServiceStatus)42 IOException (java.io.IOException)41 SQLException (android.database.SQLException)36 SQLiteOpenHelper (android.database.sqlite.SQLiteOpenHelper)36 RemoteException (android.os.RemoteException)36 Pair (android.util.Pair)31 MediumTest (android.test.suitebuilder.annotation.MediumTest)30 Account (android.accounts.Account)29 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)25 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)22 HashMap (java.util.HashMap)21