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

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

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

origin: greenrobot/greenDAO

@Override
public long simpleQueryForLong() {
  return delegate.simpleQueryForLong();
}
origin: stackoverflow.com

 String sql = "SELECT COUNT(*) FROM table_name";
SQLiteStatement statement = db.compileStatement(sql);
long result = statement.simpleQueryForLong();
origin: stackoverflow.com

 public int getMaxColumnData() {

  mDb = mDbManager.getReadableDatabase();
  final SQLiteStatement stmt = mDb
      .compileStatement("SELECT MAX(column) FROM Table");

  return (int) stmt.simpleQueryForLong();
}
origin: stackoverflow.com

SQLiteStatement s = mDb.compileStatement( "select count(*) from users where uname='" + loginname + "' and pwd='" + loginpass + "'; " );
long count = s.simpleQueryForLong();
origin: yigit/android-priority-jobqueue

@Override
public int countReadyJobs(@NonNull Constraint constraint) {
  final Where where = createWhere(constraint);
  final long result = where.countReady(db, reusedStringBuilder).simpleQueryForLong();
  return (int) result;
}
origin: yigit/android-priority-jobqueue

/**
 * {@inheritDoc}
 */
@Override
public Long getNextJobDelayUntilNs(@NonNull Constraint constraint) {
  final Where where = createWhere(constraint);
  try {
    long result = where.nextJobDelayUntil(db, sqlHelper).simpleQueryForLong();
    return result == Params.FOREVER ? null : result;
  } catch (SQLiteDoneException empty) {
    return null;
  }
}
origin: stackoverflow.com

  return stmt.simpleQueryForLong();
} finally {
  stmt.close();
origin: yigit/android-priority-jobqueue

/**
 * {@inheritDoc}
 */
@Override
public int count() {
  SQLiteStatement stmt = sqlHelper.getCountStatement();
  stmt.clearBindings();
  stmt.bindLong(1, sessionId);
  return (int) stmt.simpleQueryForLong();
}
origin: robolectric/robolectric

@Test(expected = SQLiteDoneException.class)
public void simpleQueryForLongThrowsSQLiteDoneExceptionTest() throws Exception {
 //throw SQLiteDOneException if no rows returned.
 SQLiteStatement stmt = database.compileStatement("SELECT * FROM `countme` where `name`= 'cessationoftime'");
 stmt.simpleQueryForLong();
}
origin: robolectric/robolectric

@Test
public void simpleQueryTest() throws Exception {
 SQLiteStatement stmt = database.compileStatement("SELECT count(*) FROM `countme`");
 assertThat(stmt.simpleQueryForLong()).isEqualTo(0L);
 assertThat(stmt.simpleQueryForString()).isEqualTo("0");
 SQLiteStatement insertStatement = database.compileStatement("INSERT INTO `countme` (`name` ,`lastUsed` ) VALUES (?,?)");
 insertStatement.bindString(1, "Leg Press");
 insertStatement.bindLong(2, 0);
 insertStatement.executeInsert();
 assertThat(stmt.simpleQueryForLong()).isEqualTo(1L);
 assertThat(stmt.simpleQueryForString()).isEqualTo("1");
 insertStatement.bindString(1, "Bench Press");
 insertStatement.bindLong(2, 1);
 insertStatement.executeInsert();
 assertThat(stmt.simpleQueryForLong()).isEqualTo(2L);
 assertThat(stmt.simpleQueryForString()).isEqualTo("2");
}
origin: yahoo/squidb

@Override
public long simpleQueryForLong() {
  return statement.simpleQueryForLong();
}
origin: stackoverflow.com

 private static final String DB_TABLE_PLACES = "Places";
private SQLiteDatabase mDatabase;

private long fetchPlacesCount() {
  String sql = "SELECT COUNT(*) FROM " + DB_TABLE_PLACES;
  SQLiteStatement statement = mDatabase.compileStatement(sql);
  long count = statement.simpleQueryForLong();
  return count;
}
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: 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: stackoverflow.com

 public int countjournals() {
  SQLiteStatement dbJournalCountQuery;
  dbJournalCountQuery = mDb.compileStatement("select count(*) from" + DATABASE_JOURNAL_TABLE);
  return (int) dbJournalCountQuery.simpleQueryForLong();
}
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: redfish64/TinyTravelTracker

public static long runQueryWithStrings(SQLiteDatabase db, String stmtStr, String ... str) {
  SQLiteStatement s = createOrGetStatement(db, stmtStr);
  for(int i = 0; i < str.length; i++)
  {
    s.bindString(i+1, str[i]);
  }
  
  return s.simpleQueryForLong();
}
origin: offensive-security/nethunter-app

long getCount() {
  String sql = "SELECT COUNT(*) FROM " + SearchSploit.TABLE;
  SQLiteDatabase db = this.getWritableDatabase();
  SQLiteStatement statement = db.compileStatement(sql);
  long count = statement.simpleQueryForLong();
  return count;
}
origin: stackoverflow.com

 public boolean someMethod(String s) {
  SQLiteDatabase db = getReadableDatabase();
  String sql = "select count(*) from " + TABLE_NAME + " where "
      + COLUMN_WORD + " = " + DatabaseUtils.sqlEscapeString(s);
  SQLiteStatement statement = db.compileStatement(sql);

  try {
    return statement.simpleQueryForLong() > 0;
  } finally {
    statement.close();
  }
}
origin: kochka/WeightLogger

static public int getCount(Context context) {
 SQLiteStatement statement = getDb(context).compileStatement("SELECT COUNT(*) FROM " + TABLE_NAME);
 int result = (int) statement.simpleQueryForLong();
 statement.close();
 return result;
}
android.database.sqliteSQLiteStatementsimpleQueryForLong

Popular methods of SQLiteStatement

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

Popular in Java

  • Finding current android device location
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • JLabel (javax.swing)
  • Sublime Text for Python
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