Java Code Examples for android.database.sqlite.SQLiteStatement.clearBindings()

The following are Jave code examples for showing how to use clearBindings() of the android.database.sqlite.SQLiteStatement class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: MinimalismJotter   File: TagDao.java   Source Code and License Vote up 6 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, Tag entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String tag = entity.getTag();
    if (tag != null) {
        stmt.bindString(2, tag);
    }
 
    Integer size = entity.getSize();
    if (size != null) {
        stmt.bindLong(3, size);
    }
}
 
Example 2
Project: Expert-Android-Programming   File: PhotoItemDao.java   Source Code and License Vote up 6 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, PhotoItem entity) {
	 stmt.clearBindings();
	 
     int c = 0;         
     Long id = entity.getId();
     ++c;
     if (id != null) {
     	 stmt.bindLong(c, id);
     }
    ++c; stmt.bindString(c, handleNull(entity.get_id()));
    ++c; stmt.bindString(c, handleNull(entity.getName()));
    ++c; stmt.bindString(c, handleNull(entity.getPath()));
    ++c; stmt.bindString(c, handleNull(entity.getTag()));
    ++c; stmt.bindLong(c, entity.isStatus()?1:0);
}
 
Example 3
Project: sctalk   File: MessageDao.java   Source Code and License Vote up 6 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, MessageEntity entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
    stmt.bindLong(2, entity.getMsgId());
    stmt.bindLong(3, entity.getFromId());
    stmt.bindLong(4, entity.getToId());
    stmt.bindString(5, entity.getSessionKey());
    stmt.bindString(6, entity.getContent());
    stmt.bindLong(7, entity.getMsgType());
    stmt.bindLong(8, entity.getDisplayType());
    stmt.bindLong(9, entity.getStatus());
    stmt.bindLong(10, entity.getCreated());
    stmt.bindLong(11, entity.getUpdated());
}
 
Example 4
Project: chat-sdk-android-push-firebase   File: BLinkedAccountDao.java   Source Code and License Vote up 6 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, BLinkedAccount entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String Token = entity.getToken();
    if (Token != null) {
        stmt.bindString(2, Token);
    }
 
    Integer type = entity.getType();
    if (type != null) {
        stmt.bindLong(3, type);
    }
 
    Long BUserDaoId = entity.getBUserDaoId();
    if (BUserDaoId != null) {
        stmt.bindLong(4, BUserDaoId);
    }
}
 
Example 5
Project: Shopping_List   File: ShoppingListDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, ShoppingList entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
    stmt.bindString(2, entity.getName());
    stmt.bindLong(3, entity.getDate());
}
 
Example 6
Project: GitHub   File: RelationSource2Dao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, RelationSource2 entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    Long toOneId = entity.getToOneId();
    if (toOneId != null) {
        stmt.bindLong(2, toOneId);
    }
}
 
Example 7
Project: SlotNSlot_Android   File: DownloadsDB.java   Source Code and License Vote up 5 votes
public void updateDownloadCurrentBytes(final DownloadInfo di) {
    SQLiteStatement downloadCurrentBytes = getUpdateCurrentBytesStatement();
    downloadCurrentBytes.clearBindings();
    downloadCurrentBytes.bindLong(1, di.mCurrentBytes);
    downloadCurrentBytes.bindLong(2, di.mIndex);
    downloadCurrentBytes.execute();
}
 
Example 8
Project: weex-3d-map   File: DefaultWXStorage.java   Source Code and License Vote up 5 votes
private boolean performSetItem(String key, String value, boolean isPersistent, boolean allowRetryWhenFull) {
    SQLiteDatabase database = mDatabaseSupplier.getDatabase();
    if (database == null) {
        return false;
    }

    WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "set k-v to storage(key:" + key + ",value:" + value + ",isPersistent:" + isPersistent + ",allowRetry:" + allowRetryWhenFull + ")");
    String sql = "INSERT OR REPLACE INTO " + WXSQLiteOpenHelper.TABLE_STORAGE + " VALUES (?,?,?,?);";
    SQLiteStatement statement = null;
    String timeStamp = WXSQLiteOpenHelper.sDateFormatter.format(new Date());
    try {
        statement = database.compileStatement(sql);
        statement.clearBindings();
        statement.bindString(1, key);
        statement.bindString(2, value);
        statement.bindString(3, timeStamp);
        statement.bindLong(4, isPersistent ? 1 : 0);
        statement.execute();
        return true;
    } catch (Exception e) {
        WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute setItem :" + e.getMessage());
        if (e instanceof SQLiteFullException) {
            if (allowRetryWhenFull && trimToSize()) {
                //try again
                //setItem/setItemPersistent method only allow try once when occurred a sqliteFullException.
                WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "retry set k-v to storage(key:" + key + ",value:" + value + ")");
                return performSetItem(key, value, isPersistent, false);
            }
        }

        return false;
    } finally {
        if(statement != null) {
            statement.close();
        }
    }
}
 
Example 9
Project: Hitalk   File: UserDao.java   Source Code and License Vote up 5 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, User entity) {
    stmt.clearBindings();
 
    String userName = entity.getUserName();
    if (userName != null) {
        stmt.bindString(1, userName);
    }
 
    String nick = entity.getNick();
    if (nick != null) {
        stmt.bindString(2, nick);
    }
 
    String avatar = entity.getAvatar();
    if (avatar != null) {
        stmt.bindString(3, avatar);
    }
 
    String objectId = entity.getObjectId();
    if (objectId != null) {
        stmt.bindString(4, objectId);
    }
 
    String college = entity.getCollege();
    if (college != null) {
        stmt.bindString(5, college);
    }
 
    Integer sex = entity.getSex();
    if (sex != null) {
        stmt.bindLong(6, sex);
    }
 
    String interest = entity.getInterest();
    if (interest != null) {
        stmt.bindString(7, interest);
    }
}
 
Example 10
Project: GitHub   File: AutoincrementEntityDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, AutoincrementEntity entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
}
 
Example 11
Project: GitHub   File: AnActiveEntityDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, AnActiveEntity entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String text = entity.getText();
    if (text != null) {
        stmt.bindString(2, text);
    }
}
 
Example 12
Project: pvdisplay   File: PvDataOperations.java   Source Code and License Vote up 5 votes
public void saveMonthly(List<MonthlyPvDatum> monthlyPvData) {
    SQLiteDatabase db = pvDataHelper.getWritableDatabase();

    db.beginTransaction();
    String sql = "REPLACE INTO " + PvDataContract.MonthlyPvData.TABLE_NAME +
            "(" + PvDataContract.MonthlyPvData.COLUMN_NAME_YEAR +
            "," + PvDataContract.MonthlyPvData.COLUMN_NAME_MONTH +
            "," + PvDataContract.MonthlyPvData.COLUMN_NAME_ENERGY_GENERATED +
            ") VALUES (?,?,?);";
    SQLiteStatement statement = db.compileStatement(sql);
    double maxEnergyGenerated = Double.MIN_VALUE;
    for (MonthlyPvDatum monthlyPvDatum : monthlyPvData) {
        statement.clearBindings();
        statement.bindLong(1, monthlyPvDatum.getYear());
        statement.bindLong(2, monthlyPvDatum.getMonth());
        statement.bindDouble(3, monthlyPvDatum.getEnergyGenerated());
        statement.execute();
        maxEnergyGenerated = Math.max(maxEnergyGenerated, monthlyPvDatum.getEnergyGenerated());
    }
    db.setTransactionSuccessful();
    db.endTransaction();

    db.close();
    Log.d(TAG, "Saved " + monthlyPvData.size() + " rows of monthly PV data to database");

    RecordPvDatum recordPvDatum = loadRecord();
    if (maxEnergyGenerated > recordPvDatum.getMonthlyEnergyGenerated()) {
        recordPvDatum.setMonthlyEnergyGenerated(maxEnergyGenerated);
        saveRecord(recordPvDatum);
    }
}
 
Example 13
Project: Shopping_List   File: ProductDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, Product entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
    stmt.bindString(2, entity.getName());
    stmt.bindDouble(3, entity.getCost());
}
 
Example 14
Project: Android-SQLite-Master-Project   File: UserDao.java   Source Code and License Vote up 5 votes
private static void insertUser(@NonNull SQLiteStatement statement, @NonNull User user) {
    statement.bindLong(1, user.getId());
    bindString(statement, 2, user.getName());
    bindString(statement, 3, user.getSecondName());
    bindString(statement, 4, user.getEmail());
    bindDate(statement, 5, user.getBirthday());
    statement.executeInsert();
    statement.clearBindings();
}
 
Example 15
Project: GitHub   File: StringKeyValueEntityDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, StringKeyValueEntity entity) {
    stmt.clearBindings();
 
    String key = entity.getKey();
    if (key != null) {
        stmt.bindString(1, key);
    }
 
    String value = entity.getValue();
    if (value != null) {
        stmt.bindString(2, value);
    }
}
 
Example 16
Project: GitHub   File: ToOneTarget2Dao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, ToOneTarget2 entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
}
 
Example 17
Project: weex-uikit   File: DefaultWXStorage.java   Source Code and License Vote up 5 votes
private boolean performSetItem(String key, String value, boolean isPersistent, boolean allowRetryWhenFull) {
    SQLiteDatabase database = mDatabaseSupplier.getDatabase();
    if (database == null) {
        return false;
    }

    WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "set k-v to storage(key:" + key + ",value:" + value + ",isPersistent:" + isPersistent + ",allowRetry:" + allowRetryWhenFull + ")");
    String sql = "INSERT OR REPLACE INTO " + WXSQLiteOpenHelper.TABLE_STORAGE + " VALUES (?,?,?,?);";
    SQLiteStatement statement = null;
    String timeStamp = WXSQLiteOpenHelper.sDateFormatter.format(new Date());
    try {
        statement = database.compileStatement(sql);
        statement.clearBindings();
        statement.bindString(1, key);
        statement.bindString(2, value);
        statement.bindString(3, timeStamp);
        statement.bindLong(4, isPersistent ? 1 : 0);
        statement.execute();
        return true;
    } catch (Exception e) {
        WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute setItem :" + e.getMessage());
        if (e instanceof SQLiteFullException) {
            if (allowRetryWhenFull && trimToSize()) {
                //try again
                //setItem/setItemPersistent method only allow try once when occurred a sqliteFullException.
                WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "retry set k-v to storage(key:" + key + ",value:" + value + ")");
                return performSetItem(key, value, isPersistent, false);
            }
        }

        return false;
    } finally {
        if(statement != null) {
            statement.close();
        }
    }
}
 
Example 18
Project: OpenHub   File: TraceDao.java   Source Code and License Vote up 5 votes
@Override
protected final void bindValues(SQLiteStatement stmt, Trace entity) {
    stmt.clearBindings();
    stmt.bindString(1, entity.getId());
 
    String type = entity.getType();
    if (type != null) {
        stmt.bindString(2, type);
    }
 
    String userId = entity.getUserId();
    if (userId != null) {
        stmt.bindString(3, userId);
    }
 
    Long repoId = entity.getRepoId();
    if (repoId != null) {
        stmt.bindLong(4, repoId);
    }
 
    java.util.Date startTime = entity.getStartTime();
    if (startTime != null) {
        stmt.bindLong(5, startTime.getTime());
    }
 
    java.util.Date latestTime = entity.getLatestTime();
    if (latestTime != null) {
        stmt.bindLong(6, latestTime.getTime());
    }
 
    Integer traceNum = entity.getTraceNum();
    if (traceNum != null) {
        stmt.bindLong(7, traceNum);
    }
}
 
Example 19
Project: popomusic   File: VideoBeanDao.java   Source Code and License Vote up 4 votes
@Override
protected final void bindValues(SQLiteStatement stmt, VideoBean entity) {
    stmt.clearBindings();
 
    Long id = entity.getId();
    if (id != null) {
        stmt.bindLong(1, id);
    }
 
    String dataType = entity.getDataType();
    if (dataType != null) {
        stmt.bindString(2, dataType);
    }
 
    String title = entity.getTitle();
    if (title != null) {
        stmt.bindString(3, title);
    }
 
    String text = entity.getText();
    if (text != null) {
        stmt.bindString(4, text);
    }
 
    String description = entity.getDescription();
    if (description != null) {
        stmt.bindString(5, description);
    }
 
    String image = entity.getImage();
    if (image != null) {
        stmt.bindString(6, image);
    }
 
    String actionUrl = entity.getActionUrl();
    if (actionUrl != null) {
        stmt.bindString(7, actionUrl);
    }
    stmt.bindLong(8, entity.getShade() ? 1L: 0L);
 
    String playUrl = entity.getPlayUrl();
    if (playUrl != null) {
        stmt.bindString(9, playUrl);
    }
 
    String category = entity.getCategory();
    if (category != null) {
        stmt.bindString(10, category);
    }
    stmt.bindLong(11, entity.getDuration());
 
    String icon = entity.getIcon();
    if (icon != null) {
        stmt.bindString(12, icon);
    }
}
 
Example 20
Project: rongyunDemo   File: FriendDao.java   Source Code and License Vote up 4 votes
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, Friend entity) {
    stmt.clearBindings();
    stmt.bindString(1, entity.getUserId());

    String name = entity.getName();
    if (name != null) {
        stmt.bindString(2, name);
    }

    String portraitUri = entity.getPortraitUri();
    if (portraitUri != null) {
        stmt.bindString(3, portraitUri);
    }

    String displayName = entity.getDisplayName();
    if (displayName != null) {
        stmt.bindString(4, displayName);
    }

    String region = entity.getRegion();
    if (region != null) {
        stmt.bindString(5, region);
    }

    String phoneNumber = entity.getPhoneNumber();
    if (phoneNumber != null) {
        stmt.bindString(6, phoneNumber);
    }

    String status = entity.getStatus();
    if (status != null) {
        stmt.bindString(7, status);
    }

    Long timestamp = entity.getTimestamp();
    if (timestamp != null) {
        stmt.bindLong(8, timestamp);
    }

    String nameSpelling = entity.getNameSpelling();
    if (nameSpelling != null) {
        stmt.bindString(9, nameSpelling);
    }

    String displayNameSpelling = entity.getDisplayNameSpelling();
    if (displayNameSpelling != null) {
        stmt.bindString(10, displayNameSpelling);
    }
}