Tabnine Logo
SupportSQLiteDatabase.execSQL
Code IndexAdd Tabnine to your IDE (free)

How to use
execSQL
method
in
androidx.sqlite.db.SupportSQLiteDatabase

Best Java code snippets using androidx.sqlite.db.SupportSQLiteDatabase.execSQL (Showing top 13 results out of 315)

origin: ankidroid/Anki-Android

/**
 * WARNING: This is a convenience method that splits SQL scripts into separate queries with semicolons (;) 
 * as the delimiter. Only use this method on internal functions where we can guarantee that the script does
 * not contain any non-statement-terminating semicolons.
 */
public void executeScript(String sql) {
  mMod = true;
  String[] queries = sql.split(";");
  for(String query : queries) {
    mDatabase.execSQL(query);
  }
}
origin: ankidroid/Anki-Android

public void execute(String sql, Object[] object) {
  String s = sql.trim().toLowerCase(Locale.US);
  // mark modified?
  for (String mo : MOD_SQLS) {
    if (s.startsWith(mo)) {
      mMod = true;
      break;
    }
  }
  if (object == null) {
    this.getDatabase().execSQL(sql);
  } else {
    this.getDatabase().execSQL(sql, object);
  }
}
origin: ankidroid/Anki-Android

public void executeMany(String sql, List<Object[]> list) {
  mMod = true;
  mDatabase.beginTransaction();
  try {
    for (Object[] o : list) {
      mDatabase.execSQL(sql, o);
    }
    mDatabase.setTransactionSuccessful();
  } finally {
    mDatabase.endTransaction();
  }
}
origin: ankidroid/Anki-Android

mSrc.getDb().getDatabase().execSQL("ATTACH '" + path + "' AS DST_DB");
    .execSQL("INSERT INTO DST_DB.cards select * from cards where id in " + Utils.ids2str(cids));
Set<Long> nids = new HashSet<>(mSrc.getDb().queryColumn(Long.class,
    "select nid from cards where id in " + Utils.ids2str(cids), 0));
ArrayList<Long> uniqueNids = new ArrayList<>(nids);
String strnids = Utils.ids2str(uniqueNids);
mSrc.getDb().getDatabase().execSQL("INSERT INTO DST_DB.notes select * from notes where id in " + strnids);
  Timber.d("Copy history and revlog");
  mSrc.getDb().getDatabase()
      .execSQL("insert into DST_DB.revlog select * from revlog where cid in " + Utils.ids2str(cids));
  mSrc.getDb().getDatabase().execSQL("DETACH DST_DB");
  dst.reopen();
} else {
  Timber.d("Detaching destination db and reopening");
  mSrc.getDb().getDatabase().execSQL("DETACH DST_DB");
  dst.reopen();
origin: cbeyls/fosdem-companion-android

database.execSQL("CREATE TABLE tmp_"
    + EventEntity.TABLE_NAME
    + " (id INTEGER PRIMARY KEY NOT NULL, day_index INTEGER NOT NULL, start_time INTEGER, end_time INTEGER, room_name TEXT, slug TEXT, track_id INTEGER NOT NULL, abstract TEXT, description TEXT);");
database.execSQL("INSERT INTO tmp_" + EventEntity.TABLE_NAME + " SELECT * FROM " + EventEntity.TABLE_NAME);
database.execSQL("DROP TABLE " + EventEntity.TABLE_NAME);
database.execSQL("ALTER TABLE tmp_" + EventEntity.TABLE_NAME + " RENAME TO " + EventEntity.TABLE_NAME);
database.execSQL("CREATE INDEX event_day_index_idx ON " + EventEntity.TABLE_NAME + " (day_index)");
database.execSQL("CREATE INDEX event_start_time_idx ON " + EventEntity.TABLE_NAME + " (start_time)");
database.execSQL("CREATE INDEX event_end_time_idx ON " + EventEntity.TABLE_NAME + " (end_time)");
database.execSQL("CREATE INDEX event_track_id_idx ON " + EventEntity.TABLE_NAME + " (track_id)");
database.execSQL("CREATE TABLE tmp_" + Link.TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, event_id INTEGER NOT NULL, url TEXT NOT NULL, description TEXT);");
database.execSQL("INSERT INTO tmp_" + Link.TABLE_NAME + " SELECT `rowid` AS id, event_id, url, description FROM " + Link.TABLE_NAME);
database.execSQL("DROP TABLE " + Link.TABLE_NAME);
database.execSQL("ALTER TABLE tmp_" + Link.TABLE_NAME + " RENAME TO " + Link.TABLE_NAME);
database.execSQL("CREATE INDEX link_event_id_idx ON " + Link.TABLE_NAME + " (event_id)");
database.execSQL("CREATE TABLE tmp_" + Track.TABLE_NAME + " (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL, type TEXT NOT NULL);");
database.execSQL("INSERT INTO tmp_" + Track.TABLE_NAME + " SELECT * FROM " + Track.TABLE_NAME);
database.execSQL("DROP TABLE " + Track.TABLE_NAME);
database.execSQL("ALTER TABLE tmp_" + Track.TABLE_NAME + " RENAME TO " + Track.TABLE_NAME);
database.execSQL("CREATE UNIQUE INDEX track_main_idx ON " + Track.TABLE_NAME + " (name, type)");
database.execSQL("CREATE TABLE tmp_" + Day.TABLE_NAME + " (`index` INTEGER PRIMARY KEY NOT NULL, date INTEGER NOT NULL);");
database.execSQL("INSERT INTO tmp_" + Day.TABLE_NAME + " SELECT _index as `index`, date FROM " + Day.TABLE_NAME);
database.execSQL("DROP TABLE " + Day.TABLE_NAME);
database.execSQL("ALTER TABLE tmp_" + Day.TABLE_NAME + " RENAME TO " + Day.TABLE_NAME);
database.execSQL("CREATE TABLE tmp_" + Bookmark.TABLE_NAME + " (event_id INTEGER PRIMARY KEY NOT NULL);");
origin: commonsguy/cwac-saferoom

@Override
public void onCreate(SupportSQLiteDatabase db) {
 db.execSQL("CREATE TABLE foo (bar, goo);");
 db.execSQL("INSERT INTO foo (bar, goo) VALUES (?, ?)",
  new Object[] {1, "two"});
}
origin: commonsguy/cwac-saferoom

@Override
public void onCreate(SupportSQLiteDatabase db) {
 db.execSQL("CREATE TABLE foo (bar, goo);");
 db.execSQL("INSERT INTO foo (bar, goo) VALUES (?, ?)",
  new Object[] {1, "two"});
}
origin: commonsguy/cwac-saferoom

@Override
public void onCreate(SupportSQLiteDatabase db) {
 db.execSQL("CREATE TABLE foo (bar, goo);");
 db.execSQL("INSERT INTO foo (bar, goo) VALUES (?, ?)",
  new Object[] {1, "two"});
}
origin: oliexdev/openScale

try {
  database.execSQL("DROP INDEX index_scaleMeasurements_userId_datetime");
  database.execSQL("ALTER TABLE scaleMeasurements RENAME TO scaleMeasurementsOld");
  database.execSQL("ALTER TABLE scaleUsers RENAME TO scaleUsersOld");
  database.execSQL("CREATE TABLE scaleMeasurements"
      + " (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
      + " userId INTEGER NOT NULL, enabled INTEGER NOT NULL,"
  database.execSQL("CREATE TABLE scaleUsers "
      + "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "
      + "username TEXT NOT NULL, birthday INTEGER NOT NULL, bodyHeight REAL NOT NULL, "
  database.execSQL("CREATE UNIQUE INDEX index_scaleMeasurements_userId_datetime"
      + " ON scaleMeasurements (userId, datetime)");
  database.execSQL("INSERT INTO scaleMeasurements"
      + " SELECT id, userId, enabled, datetime, weight, fat, water, muscle,"
      + " 0 AS visceralFat, lbw AS lbm, waist, hip, bone, 0 AS chest,"
  database.execSQL("INSERT INTO scaleUsers"
      + " SELECT id, username, birthday, bodyHeight, scaleUnit, gender, initialWeight, goalWeight,"
      + " goalDate, 0 AS measureUnit, 0 AS activityLevel FROM scaleUsersOld");
  database.execSQL("DROP TABLE scaleMeasurementsOld");
  database.execSQL("DROP TABLE scaleUsersOld");
origin: oliexdev/openScale

try {
  database.execSQL("DROP INDEX index_scaleMeasurements_datetime");
  database.execSQL("ALTER TABLE scaleMeasurements RENAME TO scaleMeasurementsOld");
  database.execSQL("CREATE TABLE scaleMeasurements"
      + " (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
      + " userId INTEGER NOT NULL, enabled INTEGER NOT NULL,"
  database.execSQL("CREATE UNIQUE INDEX index_scaleMeasurements_userId_datetime"
      + " ON scaleMeasurements (userId, datetime)");
  database.execSQL("INSERT INTO scaleMeasurements"
      + " SELECT * FROM scaleMeasurementsOld"
      + " WHERE userId IN (SELECT id from scaleUsers)");
  database.execSQL("DROP TABLE scaleMeasurementsOld");
origin: oliexdev/openScale

try {
  database.execSQL("DROP INDEX index_scaleMeasurements_userId_datetime");
  database.execSQL("ALTER TABLE scaleMeasurements RENAME TO scaleMeasurementsOld");
  database.execSQL("CREATE TABLE scaleMeasurements"
      + " (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
      + " userId INTEGER NOT NULL, enabled INTEGER NOT NULL,"
  database.execSQL("CREATE UNIQUE INDEX index_scaleMeasurements_userId_datetime"
      + " ON scaleMeasurements (userId, datetime)");
  database.execSQL("INSERT INTO scaleMeasurements"
      + " SELECT id, userId, enabled, datetime, weight, fat, water, muscle,"
      + " visceralFat, lbm, waist, hip, bone, chest,"
  database.execSQL("DROP TABLE scaleMeasurementsOld");
origin: commonsguy/cwac-saferoom

 @Override
 public void migrate(@NonNull SupportSQLiteDatabase db) {
  db.execSQL("CREATE TABLE IF NOT EXISTS `SillyEntity` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)");
 }
};
origin: commonsguy/cwac-saferoom

@Test
public void rekey() throws IOException {
 SafeHelperFactory factory=
  SafeHelperFactory.fromUser(new SpannableStringBuilder("sekrit"));
 SupportSQLiteOpenHelper helper=
  factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 SupportSQLiteDatabase db=helper.getWritableDatabase();
 assertOriginalContent(db);
 SafeHelperFactory.rekey(db, new SpannableStringBuilder(PASSPHRASE));
 assertOriginalContent(db);
 db.execSQL("UPDATE foo SET bar=?, goo=?", new Object[] {3, "four"});
 assertUpdatedContent(db);
 db.close();
 factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
 helper=factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
  new Callback(1));
 db=helper.getWritableDatabase();
 assertUpdatedContent(db);
}
androidx.sqlite.dbSupportSQLiteDatabaseexecSQL

Popular methods of SupportSQLiteDatabase

  • close
  • query
  • beginTransaction
  • disableWriteAheadLogging
  • endTransaction
  • insert
  • setTransactionSuccessful
  • enableWriteAheadLogging
  • getPath
  • inTransaction
  • isOpen
  • isWriteAheadLoggingEnabled
  • isOpen,
  • isWriteAheadLoggingEnabled,
  • setForeignKeyConstraintsEnabled,
  • update

Popular in Java

  • Parsing JSON documents to java classes using gson
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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