Search in sources :

Example 16 with Database

use of org.greenrobot.greendao.database.Database in project Palm300Heroes by nicolite.

the class DaoMaster method newDevSession.

/**
 * WARNING: Drops all table on Upgrade! Use only during development.
 * Convenience method using a {@link DevOpenHelper}.
 */
public static DaoSession newDevSession(Context context, String name) {
    Database db = new DevOpenHelper(context, name).getWritableDb();
    DaoMaster daoMaster = new DaoMaster(db);
    return daoMaster.newSession();
}
Also used : AbstractDaoMaster(org.greenrobot.greendao.AbstractDaoMaster) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Database(org.greenrobot.greendao.database.Database) StandardDatabase(org.greenrobot.greendao.database.StandardDatabase)

Example 17 with Database

use of org.greenrobot.greendao.database.Database in project greenDAO by greenrobot.

the class DaoMaster method newDevSession.

/**
 * WARNING: Drops all table on Upgrade! Use only during development.
 * Convenience method using a {@link DevOpenHelper}.
 */
public static DaoSession newDevSession(Context context, String name) {
    Database db = new DevOpenHelper(context, name).getWritableDb();
    DaoMaster daoMaster = new DaoMaster(db);
    return daoMaster.newSession();
}
Also used : AbstractDaoMaster(org.greenrobot.greendao.AbstractDaoMaster) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Database(org.greenrobot.greendao.database.Database) StandardDatabase(org.greenrobot.greendao.database.StandardDatabase)

Example 18 with Database

use of org.greenrobot.greendao.database.Database in project greenDAO by greenrobot.

the class DeleteQuery method executeDeleteWithoutDetachingEntities.

/**
 * Deletes all matching entities without detaching them from the identity scope (aka session/cache). Note that this
 * method may lead to stale entity objects in the session cache. Stale entities may be returned when loaded by
 * their
 * primary key, but not using queries.
 */
public void executeDeleteWithoutDetachingEntities() {
    checkThread();
    Database db = dao.getDatabase();
    if (db.isDbLockedByCurrentThread()) {
        dao.getDatabase().execSQL(sql, parameters);
    } else {
        // Do TX to acquire a connection before locking this to avoid deadlocks
        // Locking order as described in AbstractDao
        db.beginTransaction();
        try {
            dao.getDatabase().execSQL(sql, parameters);
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    }
}
Also used : Database(org.greenrobot.greendao.database.Database)

Example 19 with Database

use of org.greenrobot.greendao.database.Database in project JustAndroid by chinaltz.

the class DaoMaster method newDevSession.

/**
     * WARNING: Drops all table on Upgrade! Use only during development.
     * Convenience method using a {@link DevOpenHelper}.
     */
public static DaoSession newDevSession(Context context, String name) {
    Database db = new DevOpenHelper(context, name).getWritableDb();
    DaoMaster daoMaster = new DaoMaster(db);
    return daoMaster.newSession();
}
Also used : AbstractDaoMaster(org.greenrobot.greendao.AbstractDaoMaster) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Database(org.greenrobot.greendao.database.Database) StandardDatabase(org.greenrobot.greendao.database.StandardDatabase)

Example 20 with Database

use of org.greenrobot.greendao.database.Database in project greenDAO by greenrobot.

the class EncryptedDatabaseOpenHelperTest method testEncryptedDevOpenHelper.

public void testEncryptedDevOpenHelper() {
    createApplication();
    Database db = new DevOpenHelper(getApplication(), null).getEncryptedReadableDb("password");
    assertDbEncryptedAndFunctional(db);
}
Also used : DevOpenHelper(org.greenrobot.greendao.daotest.DaoMaster.DevOpenHelper) Database(org.greenrobot.greendao.database.Database)

Aggregations

Database (org.greenrobot.greendao.database.Database)24 StandardDatabase (org.greenrobot.greendao.database.StandardDatabase)13 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)12 AbstractDaoMaster (org.greenrobot.greendao.AbstractDaoMaster)11 DevOpenHelper (org.greenrobot.greendao.daotest.DaoMaster.DevOpenHelper)2 Cursor (android.database.Cursor)1 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)1 ArrayList (java.util.ArrayList)1 DaoException (org.greenrobot.greendao.DaoException)1 OpenHelper (org.greenrobot.greendao.daotest.DaoMaster.OpenHelper)1 DatabaseStatement (org.greenrobot.greendao.database.DatabaseStatement)1 DevOpenHelper (org.greenrobot.greendao.example.DaoMaster.DevOpenHelper)1 Before (org.junit.Before)1