congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
SQLiteStatement.close
Code IndexAdd Tabnine to your IDE (free)

How to use
close
method
in
android.database.sqlite.SQLiteStatement

Best Java code snippets using android.database.sqlite.SQLiteStatement.close (Showing top 20 results out of 315)

origin: greenrobot/greenDAO

@Override
public void close() {
  delegate.close();
}
origin: k9mail/k-9

  private void close() {
    insertStatement.close();
    deleteStatement.close();
  }
}
origin: yigit/android-priority-jobqueue

  public void destroy() {
    if (countReadyStmt != null) {
      countReadyStmt.close();
      countReadyStmt = null;
    }
    if (nextJobDelayUntilStmt != null) {
      nextJobDelayUntilStmt.close();
      nextJobDelayUntilStmt = null;
    }
  }
}
origin: kaaproject/kaa

 private void tryCloseStatement(SQLiteStatement statement) {
  if (statement != null) {
   statement.close();
  }
 }
}
origin: stackoverflow.com

  return stmt.simpleQueryForLong();
} finally {
  stmt.close();
origin: robolectric/robolectric

@Test
public void testExecuteInsertShouldCloseGeneratedKeysResultSet() throws Exception {
 // NOTE:
 // As a side-effect we will get "database locked" exception
 // on rollback if generatedKeys wasn't closed
 //
 // Don't know how suitable to use Mockito here, but
 // it will be a little bit simpler to test ShadowSQLiteStatement
 // if actualDBStatement will be mocked
 database.beginTransaction();
 try {
  SQLiteStatement insertStatement = database.compileStatement("INSERT INTO `routine` " +
    "(`name` ,`lastUsed`) VALUES ('test',0)");
  try {
   insertStatement.executeInsert();
  } finally {
   insertStatement.close();
  }
 } finally {
  database.endTransaction();
 }
}
origin: robolectric/robolectric

 @Test
 public void testCloseShouldCloseUnderlyingPreparedStatement() throws Exception {
  SQLiteStatement insertStatement = database.compileStatement("INSERT INTO `routine` (`name`) VALUES (?)");
  insertStatement.bindString(1, "Hand Press");
  insertStatement.close();
  try {
   insertStatement.executeInsert();
   fail();
  } catch (Exception e) {
   assertThat(e).isInstanceOf(IllegalStateException.class);
  }
 }
}
origin: yahoo/squidb

@Override
public void close() {
  statement.close();
}
origin: yahoo/squidb

@Override
public void ensureSqlCompiles(String sql) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    SQLiteStatement statement = null;
    try {
      statement = db.compileStatement(sql);
    } finally {
      if (statement != null) {
        statement.close();
      }
    }
  } else {
    Cursor c = db.rawQuery(sql, null);
    if (c != null) {
      c.close();
    }
  }
}
origin: yahoo/squidb

@Override
public int executeUpdateDelete(String sql, Object[] bindArgs) {
  SQLiteStatement statement = null;
  try {
    statement = db.compileStatement(sql);
    SquidCursorFactory.bindArgumentsToProgram(statement, bindArgs);
    return statement.executeUpdateDelete();
  } finally {
    if (statement != null) {
      statement.close();
    }
  }
}
origin: yahoo/squidb

@Override
public long executeInsert(String sql, Object[] bindArgs) {
  SQLiteStatement statement = null;
  try {
    statement = db.compileStatement(sql);
    SquidCursorFactory.bindArgumentsToProgram(statement, bindArgs);
    return statement.executeInsert();
  } finally {
    if (statement != null) {
      statement.close();
    }
  }
}
origin: yahoo/squidb

@Override
public long simpleQueryForLong(String sql, Object[] bindArgs) {
  SQLiteStatement statement = null;
  try {
    statement = db.compileStatement(sql);
    SquidCursorFactory.bindArgumentsToProgram(statement, bindArgs);
    return statement.simpleQueryForLong();
  } finally {
    if (statement != null) {
      statement.close();
    }
  }
}
origin: yahoo/squidb

@Override
public String simpleQueryForString(String sql, Object[] bindArgs) {
  SQLiteStatement statement = null;
  try {
    statement = db.compileStatement(sql);
    SquidCursorFactory.bindArgumentsToProgram(statement, bindArgs);
    return statement.simpleQueryForString();
  } finally {
    if (statement != null) {
      statement.close();
    }
  }
}
origin: weexteam/weex-hackernews

private long performGetLength() {
  SQLiteDatabase database = mDatabaseSupplier.getDatabase();
  if (database == null) {
    return 0;
  }
  String sql = "SELECT count(" + WXSQLiteOpenHelper.COLUMN_KEY + ") FROM " + WXSQLiteOpenHelper.TABLE_STORAGE;
  SQLiteStatement statement = null;
  try {
    statement = database.compileStatement(sql);
    return statement.simpleQueryForLong();
  } catch (Exception e) {
    WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getLength:" + e.getMessage());
    return 0;
  } finally {
    if(statement != null) {
      statement.close();
    }
  }
}
origin: com.j256.ormlite/ormlite-android

/**
 * We can't use IOUtils here because older versions didn't implement Closeable.
 */
private void closeQuietly(SQLiteStatement statement) {
  if (statement != null) {
    statement.close();
  }
}
origin: weexteam/weex-hackernews

} finally {
  if(statement != null) {
    statement.close();
origin: stackoverflow.com

 long sumValue = -1L;
Database db = ((Application)SugarApp.getSugarContext()).obtainDatabase();
SQLiteDatabase sqLiteDatabase = db.getDB();
SQLiteStatement sqLiteStatement = sqLiteDatabase.compileStatement(
  "SELECT SUM(column_name) FROM table_name");
try {
  sumValue = sqLiteStatement.simpleQueryForLong();
} catch (Exception var16) {
  var16.printStackTrace();
} finally {
  sqLiteStatement.close();
}
origin: AppLozic/Applozic-Android-SDK

  public static boolean isTableEmpty(SQLiteDatabase database, String table) {
    String sql = "SELECT COUNT(*) FROM " + table;
    SQLiteStatement statement = database.compileStatement(sql);
    long records = statement.simpleQueryForLong();
    statement.close();
    return records == 0;
  }
}
origin: stackoverflow.com

 SQLiteDatabase db = ...; // get your database
String sql = "UPDATE tableName SET columnName = columnName + 1 WHERE id = 1";
SQLiteStatement statement = db.compileStatement(sql);
int affected = statement.executeUpdateDelete();
statement.close();
origin: stackoverflow.com

 SQLiteDatabase db = dbHelper.getWritableDatabase();
SQLiteStatement stmt = db.compileStatement("INSERT INTO SomeTable (name, age) values (?,?)");
// Careful! The index begins at 1, not 0 !!
stmt.bindString(1, "Jon");
stmt.bindLong(2, 48L);
stmt.execute();
// Also important! Clean up after yourself.
stmt.close();
android.database.sqliteSQLiteStatementclose

Popular methods of SQLiteStatement

  • bindLong
  • bindString
  • clearBindings
  • executeInsert
  • execute
  • bindDouble
  • bindBlob
  • executeUpdateDelete
  • simpleQueryForLong
  • bindNull
  • simpleQueryForString
  • bindAllArgsAsStrings
  • simpleQueryForString,
  • bindAllArgsAsStrings,
  • bindDate,
  • bindInt,
  • bindInteger,
  • bindValue,
  • simpleQueryForBlobFileDescriptor,
  • toString

Popular in Java

  • Updating database using SQL prepared statement
  • setScale (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • onCreateOptionsMenu (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now