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 deleteAll.
public void deleteAll() {
Logger.d("Deleting all teams");
SQLiteDatabase db = getWritableDatabase();
db.delete(TEAMS_TABLE_NAME, null, null);
}
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;
}
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);
}
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;
}
Aggregations