当前位置: 首页>>代码示例>>Java>>正文


Java SQLiteDatabase.compileStatement方法代码示例

本文整理汇总了Java中android.database.sqlite.SQLiteDatabase.compileStatement方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteDatabase.compileStatement方法的具体用法?Java SQLiteDatabase.compileStatement怎么用?Java SQLiteDatabase.compileStatement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.database.sqlite.SQLiteDatabase的用法示例。


在下文中一共展示了SQLiteDatabase.compileStatement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createInsertStatement

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
SQLiteStatement createInsertStatement(SQLiteDatabase database) {
  return database.compileStatement("INSERT INTO " + TABLE_NAME + " (" + ADDRESS + ", " +
                                                                    PERSON + ", " +
                                                                    DATE_SENT + ", " +
                                                                    DATE_RECEIVED  + ", " +
                                                                    PROTOCOL + ", " +
                                                                    READ + ", " +
                                                                    STATUS + ", " +
                                                                    TYPE + ", " +
                                                                    REPLY_PATH_PRESENT + ", " +
                                                                    SUBJECT + ", " +
                                                                    BODY + ", " +
                                                                    SERVICE_CENTER +
                                                                    ", " + THREAD_ID + ") " +
                                   " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:17,代码来源:SmsDatabase.java

示例2: createItem

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public int createItem(int list_id, String label)
{
    Log.v(L.TAG, "DataManager.createItem(): Insert item " + label);

    SQLiteDatabase db = helper.getWritableDatabase();
    SQLiteStatement stmt = db.compileStatement("insert into items (list_id,label,active) values (?,?,?)");        
    stmt.bindLong(1, list_id);
    stmt.bindString(2, label);
    stmt.bindLong(3, 1);
    long id = stmt.executeInsert();
    stmt.close();
    db.close();
    
    Log.d(L.TAG, "DataManager.createItem(): Inserted item and got id " + id);
    if(id == -1)
    {
        Log.e(L.TAG, "DataManager.createItem(): Attempt to insert item failed. Got " + id + " from executeInsert()");
    }
    return (int)id;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:21,代码来源:DataManager.java

示例3: insert

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public Uri insert(Uri uri, ContentValues values) {
	SQLiteDatabase sqlDb = dbHelper.getWritableDatabase();
	
	List<String> segments = uri.getPathSegments();
	String recordId = segments.get(1);
	String name = segments.get(3);

       String insertView = "Insert or replace into views (record_id, name, query, date_synced) values(?,?,?,?)";

       SQLiteStatement insertViewStmt = sqlDb.compileStatement(insertView);

       insertViewStmt.bindString(1, recordId);
       insertViewStmt.bindString(2, name);
       insertViewStmt.bindString(3, values.getAsString("query"));
       insertViewStmt.bindString(4, values.getAsString("date_synced"));
       insertViewStmt.execute();
       
       getContext()
               .getContentResolver()
               .notifyChange(uri, null);
      
       return uri;
}
 
开发者ID:Microsoft,项目名称:healthvault-java-sdk,代码行数:24,代码来源:ViewProvider.java

示例4: addAll

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的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

示例5: saveUserMessagesRelations

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public static void saveUserMessagesRelations(@NonNull SQLiteDatabase database,
                                             @NonNull User user) {
    if (Utils.isNullOrEmpty(user.getMessages())) {
        return;
    }

    final SQLiteStatement statement = database.compileStatement(UserMessagesRelationContract.Script.Insert.INSERT);
    try {
        database.beginTransaction();
        for (Message message : user.getMessages())
            insertUserMessage(statement, user.getId(), message.getId());
        database.setTransactionSuccessful();
    } finally {
        database.setTransactionSuccessful();
    }
}
 
开发者ID:shevart,项目名称:Android-SQLite-Master-Project,代码行数:17,代码来源:UserMessagesRelationDao.java

示例6: countItemsInList

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
private int countItemsInList(SQLiteDatabase db, int listId)
{
    SQLiteStatement stmt = db.compileStatement("select count(*) from items where list_id=?");        
    stmt.bindLong(1, listId);
    int rv = (int)stmt.simpleQueryForLong();
    stmt.close();
    
    return rv;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:10,代码来源:DataManager.java

示例7: blobFileDescriptorForQuery

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
 * Utility method to run the query on the db and return the blob value in the
 * first column of the first row.
 *
 * @return A read-only file descriptor for a copy of the blob value.
 */
public static ParcelFileDescriptor blobFileDescriptorForQuery(SQLiteDatabase db,
                                                              String query, String[] selectionArgs) {
    SQLiteStatement prog = db.compileStatement(query);
    try {
        return blobFileDescriptorForQuery(prog, selectionArgs);
    } finally {
        prog.close();
    }
}
 
开发者ID:kkmike999,项目名称:KBUnitTest,代码行数:16,代码来源:ShadowDatabaseUtils.java

示例8: createFiles

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的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

示例9: updateLocation

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的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,项目名称:MapaDeIgarassu,代码行数:12,代码来源:DataBaseUtil.java

示例10: executeInsert

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
private <T> T executeInsert(
        SQLiteDatabase database,
        String query,
        ExecuteResultHandler<T> handler) {
    SQLiteStatement statement = database.compileStatement(query);
    long count = statement.executeInsert();
    return handler.handleInsert(count);
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:9,代码来源:RongDatabaseDriver.java

示例11: save

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public static User save(@NonNull SQLiteDatabase database, @NonNull User user) {
    final SQLiteStatement statement = database.compileStatement(UserContract.Script.Insert.INSERT);
    try {
        database.beginTransaction();
        insertUser(statement, user);
        database.setTransactionSuccessful();
    } finally {
        database.endTransaction();
    }
    return user;
}
 
开发者ID:shevart,项目名称:Android-SQLite-Master-Project,代码行数:12,代码来源:UserDao.java

示例12: countInactiveItemsInList

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
private int countInactiveItemsInList(SQLiteDatabase db, int listId)
{
    SQLiteStatement stmt = db.compileStatement("select count(*) from items where list_id=? and active=1");        
    stmt.bindLong(1, listId);
    int rv = (int)stmt.simpleQueryForLong();
    stmt.close();
    
    return rv;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:10,代码来源:DataManager.java

示例13: deleteItem

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void deleteItem(int itemId)
{
    Log.d(L.TAG, "Deleting item " + itemId);

    SQLiteDatabase db = helper.getWritableDatabase();
    
    SQLiteStatement stmt = db.compileStatement("delete from items where id=?");        
    stmt.bindLong(1, itemId);
    stmt.execute();
    stmt.close();
    db.close();
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:13,代码来源:DataManager.java

示例14: performSetItem

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的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:erguotou520,项目名称:weex-uikit,代码行数:38,代码来源:DefaultWXStorage.java

示例15: stringForQuery

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
 * Utility method to run the query on the db and return the value in the
 * first column of the first row.
 */
public static String stringForQuery(SQLiteDatabase db, String query, String[] selectionArgs) {
    SQLiteStatement prog = db.compileStatement(query);
    try {
        return stringForQuery(prog, selectionArgs);
    } finally {
        prog.close();
    }
}
 
开发者ID:kkmike999,项目名称:KBUnitTest,代码行数:13,代码来源:ShadowDatabaseUtils.java


注:本文中的android.database.sqlite.SQLiteDatabase.compileStatement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。