Example usage for android.database.sqlite SQLiteStatement bindDouble

List of usage examples for android.database.sqlite SQLiteStatement bindDouble

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteStatement bindDouble.

Prototype

public void bindDouble(int index, double value) 

Source Link

Document

Bind a double value to this statement.

Usage

From source file:com.ichi2.anki.SyncClient.java

private void updateMedia(JSONArray media) {
    AnkiDb ankiDB = AnkiDatabaseManager.getDatabase(mDeck.getDeckPath());
    ArrayList<String> mediaIds = new ArrayList<String>();

    String sql = "INSERT OR REPLACE INTO media (id, filename, size, created, originalPath, description) "
            + "VALUES(?,?,?,?,?,?)";
    SQLiteStatement statement = ankiDB.getDatabase().compileStatement(sql);
    int len = media.length();
    for (int i = 0; i < len; i++) {
        try {//from  ww w. ja v  a 2s .c  om
            JSONArray m = media.getJSONArray(i);

            // Grab media ids, to delete them later
            String id = m.getString(0);
            mediaIds.add(id);

            // id
            statement.bindString(1, id);
            // filename
            statement.bindString(2, m.getString(1));
            // size
            statement.bindString(3, m.getString(2));
            // created
            statement.bindDouble(4, m.getDouble(3));
            // originalPath
            statement.bindString(5, m.getString(4));
            // description
            statement.bindString(6, m.getString(5));

            statement.execute();
        } catch (JSONException e) {
            Log.i(AnkiDroidApp.TAG, "JSONException = " + e.getMessage());
        }
    }
    statement.close();

    ankiDB.getDatabase().execSQL("DELETE FROM mediaDeleted WHERE mediaId IN " + Utils.ids2str(mediaIds));
}