Search in sources :

Example 26 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.usefulModule.standuptimer.model.Team) Cursor(android.database.Cursor)

Example 27 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project UltimateAndroid by cymcsg.

the class TeamDAO method deleteAll.

public void deleteAll() {
    Logger.d("Deleting all teams");
    SQLiteDatabase db = getWritableDatabase();
    db.delete(TEAMS_TABLE_NAME, null, null);
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 28 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.usefulModule.standuptimer.model.Team) Cursor(android.database.Cursor)

Example 29 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project android-job by evernote.

the class DatabaseUpgradeTest method createJobs.

private void createJobs(UpgradeAbleJobOpenHelper openHelper) {
    SQLiteDatabase database = openHelper.getWritableDatabase();
    ContentValues contentValues = openHelper.createBaseContentValues(1);
    contentValues.put(JobStorage.COLUMN_START_MS, 60_000L);
    contentValues.put(JobStorage.COLUMN_END_MS, 120_000L);
    database.insert(JobStorage.JOB_TABLE_NAME, null, contentValues);
    contentValues = openHelper.createBaseContentValues(2);
    contentValues.put(JobStorage.COLUMN_INTERVAL_MS, 60_000L);
    database.insert(JobStorage.JOB_TABLE_NAME, null, contentValues);
    contentValues = openHelper.createBaseContentValues(3);
    contentValues.put(JobStorage.COLUMN_INTERVAL_MS, TimeUnit.MINUTES.toMillis(20));
    database.insert(JobStorage.JOB_TABLE_NAME, null, contentValues);
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 30 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project android_frameworks_base by ParanoidAndroid.

the class ContextImpl method openOrCreateDatabase.

@Override
public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, DatabaseErrorHandler errorHandler) {
    File f = validateFilePath(name, true);
    int flags = SQLiteDatabase.CREATE_IF_NECESSARY;
    if ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) {
        flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING;
    }
    SQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), factory, flags, errorHandler);
    setFilePermissionsFromMode(f.getPath(), mode, 0);
    return db;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) File(java.io.File)

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