Code example for SQLiteDatabase

Methods: rawQuery, close

0
  public T execute() { 
    SQLiteDatabase db = ORMDroidApplication.getDefaultDatabase();
    try { 
      return execute(db);
    } finally { 
      db.close();
    } 
  } 
   
  /**  
   * Execute the query on the specified database, returning only a single result. 
   * If the query would return multiple results, only the first will be returned by this method.  
   */ 
  public T execute(SQLiteDatabase db) {
    EntityMapping map = Entity.getEntityMappingEnsureSchema(db, mClass);
     
    if (sqlCache1 == null) {
      sqlCache1 = generate(1);
    } 
    String sql = sqlCache1;
    Log.v(TAG, sql);
    Cursor c = db.rawQuery(sql, null);
    if (c.moveToFirst()) {
      return map.<T>load(db, c);
    } else { 
      return null; 
    } 
  }