當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLiteStatement.execute方法代碼示例

本文整理匯總了Java中android.database.sqlite.SQLiteStatement.execute方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteStatement.execute方法的具體用法?Java SQLiteStatement.execute怎麽用?Java SQLiteStatement.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.sqlite.SQLiteStatement的用法示例。


在下文中一共展示了SQLiteStatement.execute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteWallpapers

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void deleteWallpapers(@NonNull List<Wallpaper> wallpapers) {
    if (!openDatabase()) {
        LogUtil.e("Database error: deleteWallpapers() failed to open database");
        return;
    }

    String query = "DELETE FROM " +TABLE_WALLPAPERS+ " WHERE " +KEY_URL+ " = ?";
    SQLiteStatement statement = mDatabase.get().mSQLiteDatabase.compileStatement(query);
    mDatabase.get().mSQLiteDatabase.beginTransaction();

    for (Wallpaper wallpaper : wallpapers) {
        statement.clearBindings();
        statement.bindString(1, wallpaper.getUrl());
        statement.execute();
    }

    mDatabase.get().mSQLiteDatabase.setTransactionSuccessful();
    mDatabase.get().mSQLiteDatabase.endTransaction();
}
 
開發者ID:danimahardhika,項目名稱:wallpaperboard,代碼行數:20,代碼來源:Database.java

示例2: addAll

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
static void addAll(SQLiteDatabase database, List<OpenLocateLocation> locations) {
    if (database == null || locations == null || locations.isEmpty()) {
        return;
    }

    SQLiteStatement statement = database.compileStatement(BULK_INSERT_LOCATION);

    database.beginTransaction();
    for (OpenLocateLocation location : locations) {
        statement.clearBindings();
        statement.bindString(COLUMN_LOCATION_INDEX, location.getJson().toString());
        statement.bindLong(2, location.getCreated().getTime());
        statement.execute();
    }

    database.setTransactionSuccessful();
    database.endTransaction();
}
 
開發者ID:OpenLocate,項目名稱:openlocate-android,代碼行數:19,代碼來源:LocationTable.java

示例3: put

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
void put(Map<String, String> insertables) {
    String sql = "INSERT INTO preferences_storage (primkey, value) VALUES (?, ?)";
    SQLiteStatement stmt = workingDB.get().compileStatement(sql);

    for (Map.Entry<String, String> entry : insertables.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        stmt.bindString(1, key);
        stmt.bindString(2, value);
        stmt.execute();
        stmt.clearBindings();
        liveUpdate(key, value);
    }
    stmt.close();
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:16,代碼來源:Storage.java

示例4: updateWallpapers

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void updateWallpapers(@NonNull List<Wallpaper> wallpapers) {
    if (!openDatabase()) {
        LogUtil.e("Database error: updateWallpapers() failed to open database");
        return;
    }

    String query = "UPDATE " +TABLE_WALLPAPERS+ " SET " +KEY_FAVORITE+ " = ?, " +KEY_SIZE+ " = ?, "
            +KEY_MIME_TYPE+ " = ?, " +KEY_WIDTH+ " = ?," +KEY_HEIGHT+ " = ?, " +KEY_COLOR+ " = ? "
            +"WHERE " +KEY_URL+ " = ?";
    SQLiteStatement statement = mDatabase.get().mSQLiteDatabase.compileStatement(query);
    mDatabase.get().mSQLiteDatabase.beginTransaction();

    for (Wallpaper wallpaper : wallpapers) {
        statement.clearBindings();

        statement.bindLong(1, wallpaper.isFavorite() ? 1 : 0);
        statement.bindLong(2, wallpaper.getSize());

        String mimeType = wallpaper.getMimeType();
        if (mimeType != null) {
            statement.bindString(3, mimeType);
        } else {
            statement.bindNull(3);
        }

        ImageSize dimension = wallpaper.getDimensions();
        int width = dimension == null ? 0 : dimension.getWidth();
        int height = dimension == null ? 0 : dimension.getHeight();
        statement.bindLong(4, width);
        statement.bindLong(5, height);

        statement.bindLong(6, wallpaper.getColor());
        statement.bindString(7, wallpaper.getUrl());
        statement.execute();
    }

    mDatabase.get().mSQLiteDatabase.setTransactionSuccessful();
    mDatabase.get().mSQLiteDatabase.endTransaction();
}
 
開發者ID:danimahardhika,項目名稱:wallpaperboard,代碼行數:40,代碼來源:Database.java

示例5: updateInsideSynchronized

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
protected void updateInsideSynchronized(T entity, SQLiteStatement stmt, boolean lock) {
    // To do? Check if it's worth not to bind PKs here (performance).
    bindValues(stmt, entity);
    int index = config.allColumns.length + 1;
    K key = getKey(entity);
    if (key instanceof Long) {
        stmt.bindLong(index, (Long) key);
    } else if (key == null) {
        throw new DaoException("Cannot update entity without key - was it inserted before?");
    } else {
        stmt.bindString(index, key.toString());
    }
    stmt.execute();
    attachEntity(key, entity, lock);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:AbstractDao.java

示例6: updateLocation

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void updateLocation(LocationModel locationModel) {
    SQLiteDatabase db = this.getWritableDatabase();
    SQLiteStatement stmt = db.compileStatement(Constants.UPDATE_TABLE_LOCATION);
    stmt.bindString(1, locationModel.getName());
    stmt.bindDouble(2, locationModel.getLongitude());
    stmt.bindDouble(3, locationModel.getLatitude());
    stmt.bindString(4, locationModel.getAddress());
    stmt.bindString(5, locationModel.getDescription());
    stmt.bindLong(6, locationModel.getId());
    stmt.execute();
}
 
開發者ID:gabriel-silva,項目名稱:MapaDeIgarassuAdmin,代碼行數:12,代碼來源:DataBaseUtil.java

示例7: saveDaily

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void saveDaily(List<DailyPvDatum> dailyPvData) {
    SQLiteDatabase db = pvDataHelper.getWritableDatabase();

    db.beginTransaction();
    String sql = "REPLACE INTO " + PvDataContract.DailyPvData.TABLE_NAME +
            "(" + PvDataContract.DailyPvData.COLUMN_NAME_YEAR +
            "," + PvDataContract.DailyPvData.COLUMN_NAME_MONTH +
            "," + PvDataContract.DailyPvData.COLUMN_NAME_DAY +
            "," + PvDataContract.DailyPvData.COLUMN_NAME_ENERGY_GENERATED +
            "," + PvDataContract.DailyPvData.COLUMN_NAME_PEAK_POWER +
            "," + PvDataContract.DailyPvData.COLUMN_NAME_CONDITION +
            ") VALUES (?,?,?,?,?,?);";
    SQLiteStatement statement = db.compileStatement(sql);
    double maxEnergyGenerated = Double.MIN_VALUE;
    for (DailyPvDatum dailyPvDatum : dailyPvData) {
        statement.clearBindings();
        statement.bindLong(1, dailyPvDatum.getYear());
        statement.bindLong(2, dailyPvDatum.getMonth());
        statement.bindLong(3, dailyPvDatum.getDay());
        statement.bindDouble(4, dailyPvDatum.getEnergyGenerated());
        statement.bindDouble(5, dailyPvDatum.getPeakPower());
        statement.bindString(6, dailyPvDatum.getCondition());
        statement.execute();
        maxEnergyGenerated = Math.max(maxEnergyGenerated, dailyPvDatum.getEnergyGenerated());
    }
    db.setTransactionSuccessful();
    db.endTransaction();

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

    RecordPvDatum recordPvDatum = loadRecord();
    if (maxEnergyGenerated > recordPvDatum.getDailyEnergyGenerated()) {
        recordPvDatum.setDailyEnergyGenerated(maxEnergyGenerated);
        saveRecord(recordPvDatum);
    }
}
 
開發者ID:jansipke,項目名稱:pvdisplay,代碼行數:38,代碼來源:PvDataOperations.java

示例8: onCreate

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override public void onCreate(SQLiteDatabase db) {
  SQLiteStatement createDataTable = db.compileStatement(DataTable.Statements.CREATE_TABLE);
  SQLiteStatement createRvtsTable = db.compileStatement(RvtsTable.Statements.CREATE_TABLE);
  SQLiteStatement createDirtyTable = db.compileStatement(DirtyTable.Statements.CREATE_TABLE);

  createDataTable.execute();
  createRvtsTable.execute();
  createDirtyTable.execute();
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:10,代碼來源:SqliteDBManager.java

示例9: performSetItem

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
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();
        }
    }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:38,代碼來源:DefaultWXStorage.java

示例10: updateDownloadCurrentBytes

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void updateDownloadCurrentBytes(final DownloadInfo di) {
    SQLiteStatement downloadCurrentBytes = getUpdateCurrentBytesStatement();
    downloadCurrentBytes.clearBindings();
    downloadCurrentBytes.bindLong(1, di.mCurrentBytes);
    downloadCurrentBytes.bindLong(2, di.mIndex);
    downloadCurrentBytes.execute();
}
 
開發者ID:snoozinsquatch,項目名稱:unity-obb-downloader,代碼行數:8,代碼來源:DownloadsDB.java

示例11: updateItemStarness

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void updateItemStarness(int itemId, boolean star)
{
    Log.d(L.TAG, "Setting star property of  " + itemId + " to " + star);

    SQLiteDatabase db = helper.getWritableDatabase();
    SQLiteStatement stmt = db.compileStatement("update items set star=? where id=?");        
    stmt.bindLong(1, star?1:0);
    stmt.bindLong(2, itemId);
    stmt.execute();
    stmt.close();
    db.close();
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:13,代碼來源:DataManager.java

示例12: updateListLabel

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void updateListLabel(int listId, String newLabel)
{
    Log.d(L.TAG, "Updating label of list " + listId + " to " + newLabel);

    SQLiteDatabase db = helper.getWritableDatabase();
    SQLiteStatement stmt = db.compileStatement("update lists set label=? where id=?");        
    stmt.bindString(1, newLabel);
    stmt.bindLong(2, listId);
    stmt.execute();
    stmt.close();
    db.close();
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:13,代碼來源:DataManager.java

示例13: moveItem

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void moveItem(int itemId, int toListId)
{
    Log.d(L.TAG, "Moving item " + itemId + " to list " + toListId);
    
    SQLiteDatabase db = helper.getWritableDatabase();
    SQLiteStatement stmt = db.compileStatement("update items set list_id=? where id=?");        
    stmt.bindLong(1, toListId);
    stmt.bindLong(2, itemId);
    stmt.execute();
    stmt.close();
    db.close();
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:13,代碼來源:DataManager.java

示例14: deleteInactive

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void deleteInactive(int list_id)
{
    Log.d(L.TAG, "Deleting inactive items from list " + list_id);

    SQLiteDatabase db = helper.getWritableDatabase();
    SQLiteStatement stmt = db.compileStatement("delete from items where list_id=? and active=0");        
    stmt.bindLong(1, list_id);
    stmt.execute();
    stmt.close();
    db.close();
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:12,代碼來源:DataManager.java

示例15: createFiles

import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private void createFiles(SQLiteDatabase db) {
    mFileNames = new String[mFiles];
    byte[] rawData = new byte[mFileSize+mFiles];
    Random random = new Random();
    random.nextBytes(rawData);

    ByteArrayOutputStream[] streams = new ByteArrayOutputStream[mFiles];
    for (int i = 0; i < mFiles; i++) {
        streams[i] = new ByteArrayOutputStream(mFileSize);
        streams[i].write(rawData, i, mFileSize);
        mFileNames[i] = String.valueOf(i);
    }

    SQLiteStatement insert = db.compileStatement("INSERT INTO files (filename, data) VALUES (?, ?)");
    for (int i = 0; i < mFiles; i++) {
        insert.bindString(1, mFileNames[i]);
        insert.bindBlob(2, streams[i].toByteArray());

        insert.execute();
    }
}
 
開發者ID:jasonwyatt,項目名稱:SQLite-Performance,代碼行數:22,代碼來源:DbHelper.java


注:本文中的android.database.sqlite.SQLiteStatement.execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。