Search code examples
androidandroid-sqlitesqlbrite

Use PreparedStatement with Sqlbrite


I'm migrating all my sql related codes to use Sqlbrite. Currently I have code that look something like this:

Cursor cursor;
String name;
String[] selectionArgs = { name };
cursor = database.query(MySQLiteHelper.TABLE_USER, new String[] {"id"}, "name = ? COLLATE NOCASE AND ", selectionArgs, null, null, null);

Now I need to use SqlBrite, but I want to use Prepared Statement with it. Is there any way I can do this? I googled 'SqlBrite PreparedStatement' but couldn't find anything regarding this.


Solution

  • yes, you can use executeInsert and executeUpdateDelete on your instance of BriteDatabase. They accept a SQLiteStatement as a parameter.