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


Java SQLiteDatabase.replace方法代码示例

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


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

示例1: saveContact

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void saveContact(UserInfo user, boolean isMyContact) {

        if (user == null) {
            return;
        }

        // 获取数据库链接
        SQLiteDatabase db = mHelper.getReadableDatabase();

        // 执行保存语句
        ContentValues values = new ContentValues();
        values.put(ContactTable.COL_HXID, user.getHxid());
        values.put(ContactTable.COL_NAME, user.getName());
        values.put(ContactTable.COL_NICK, user.getNick());
        values.put(ContactTable.COL_PHOTO, user.getPhoto());
        values.put(ContactTable.COL_IS_CONTACT, isMyContact ? 1 : 0);

        db.replace(ContactTable.TAB_NAME, null, values);
    }
 
开发者ID:turoDog,项目名称:KTalk,代码行数:20,代码来源:ContactTableDao.java

示例2: updateFilename

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void updateFilename(@NonNull String url, @NonNull String filename) {
    final SQLiteDatabase db = getWritableDatabase();
    ContentValues values = new ContentValues(2);
    values.put(URL, url);
    values.put(FILENAME, filename);

    Cursor c = null;
    try {
        final String query = "SELECT " + FILENAME + " FROM " + RESPONSE_FILENAME_TABLE_NAME
                + " WHERE " + URL + " = ?";
        c = db.rawQuery(query, new String[]{url});
        if (c.moveToFirst()) {
            // exist
            if (!filename.equals(c.getString(c.getColumnIndex(FILENAME)))) {
                // replace if not equal
                db.replace(RESPONSE_FILENAME_TABLE_NAME, null, values);
            }
        } else {
            // insert
            db.insert(RESPONSE_FILENAME_TABLE_NAME, null, values);
        }
    } finally {
        if (c != null) c.close();
    }
}
 
开发者ID:lingochamp,项目名称:okdownload,代码行数:26,代码来源:BreakpointSQLiteHelper.java

示例3: addNotification

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void addNotification(Reminder reminder) {
    SQLiteDatabase database = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(COL_ID, reminder.getId());
    values.put(COL_TITLE, reminder.getTitle());
    values.put(COL_CONTENT, reminder.getContent());
    values.put(COL_DATE_AND_TIME, reminder.getDateAndTime());
    values.put(COL_REPEAT_TYPE, reminder.getRepeatType());
    values.put(COL_FOREVER, reminder.getForeverState());
    values.put(COL_NUMBER_TO_SHOW, reminder.getNumberToShow());
    values.put(COL_NUMBER_SHOWN, reminder.getNumberShown());
    values.put(COL_DOSAGE, reminder.getDosage());
    values.put(COL_QUANTITY, reminder.getQuantity());
    values.put(COL_ICON, reminder.getIcon());
    values.put(COL_COLOUR, reminder.getColour());
    values.put(COL_INTERVAL, reminder.getInterval());
    database.replace(NOTIFICATION_TABLE, null, values);
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:19,代码来源:DatabaseHelper.java

示例4: saveRobotList

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
 * Save Robot list
 */
synchronized public void saveRobotList(List<RobotUser> robotList) {
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    if (db.isOpen()) {
        db.delete(UserDao.ROBOT_TABLE_NAME, null, null);
        for (RobotUser item : robotList) {
            ContentValues values = new ContentValues();
            values.put(UserDao.ROBOT_COLUMN_NAME_ID, item.getUsername());
            if (item.getNick() != null)
                values.put(UserDao.ROBOT_COLUMN_NAME_NICK, item.getNick());
            if (item.getAvatar() != null)
                values.put(UserDao.ROBOT_COLUMN_NAME_AVATAR, item.getAvatar());
            db.replace(UserDao.ROBOT_TABLE_NAME, null, values);
        }
    }
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:19,代码来源:DemoDBManager.java

示例5: addInvitation

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void addInvitation(InvationInfo invationInfo){
    //获取数据库连接
    SQLiteDatabase db = mHelper.getReadableDatabase();

    //执行添加语句
    ContentValues values = new ContentValues();
    values.put(InviteTable.COL_REASON, invationInfo.getReason());//原因
    values.put(InviteTable.COL_STATUS, invationInfo.getStatus().ordinal());//状态

    UserInfo user = invationInfo.getUser();

    if (user != null){//联系人
        values.put(InviteTable.COL_USER_HXID, invationInfo.getUser().getHxid());
        values.put(InviteTable.COL_USER_NAME, invationInfo.getUser().getName());
    }else{
        values.put(InviteTable.COL_GROUP_HXID,invationInfo.getGroup().getGroupId());
        values.put(InviteTable.COL_GROUP_NAME,invationInfo.getGroup().getGroupName());
        values.put(InviteTable.COL_USER_HXID,invationInfo.getGroup().getInvatePerson());
    }

    db.replace(InviteTable.TAB_NAME,null,values);
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:23,代码来源:InviteTableDao.java

示例6: doInBackground

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
protected Boolean doInBackground(String... params) {
    if (params.length < 4) {
        return false;
    }

    String udn = params[0];
    String containerName = params[1];
    mContainerId = params[2];
    String deviceName = params[3];

    ContentValues values = new ContentValues();
    values.put(BookmarksEntry.COLUMN_NAME_UDN, udn);
    values.put(BookmarksEntry.COLUMN_NAME_CONTAINER_NAME, containerName);
    values.put(BookmarksEntry.COLUMN_NAME_CONTAINER_ID, mContainerId);
    values.put(BookmarksEntry.COLUMN_NAME_DEVICE_NAME, deviceName);

    SQLiteDatabase db = mDbHelper.getWritableDatabase();
    Log.d(TAG, "doInBackground: writing values " + values.toString() + " to " + BookmarksEntry.TABLE_NAME);
    return db.replace(BookmarksEntry.TABLE_NAME, null, values) != -1;
}
 
开发者ID:stephenmcgruer,项目名称:simple-upnp,代码行数:22,代码来源:BookmarksWriteTask.java

示例7: saveIdentity

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void saveIdentity(long recipientId, IdentityKey identityKey, VerifiedStatus verifiedStatus,
                         boolean firstUse, long timestamp, boolean nonBlockingApproval)
{
  SQLiteDatabase database          = databaseHelper.getWritableDatabase();
  String         identityKeyString = Base64.encodeBytes(identityKey.serialize());

  ContentValues contentValues = new ContentValues();
  contentValues.put(RECIPIENT, recipientId);
  contentValues.put(IDENTITY_KEY, identityKeyString);
  contentValues.put(TIMESTAMP, timestamp);
  contentValues.put(VERIFIED, verifiedStatus.toInt());
  contentValues.put(NONBLOCKING_APPROVAL, nonBlockingApproval ? 1 : 0);
  contentValues.put(FIRST_USE, firstUse ? 1 : 0);

  database.replace(TABLE_NAME, null, contentValues);

  EventBus.getDefault().post(new IdentityRecord(recipientId, identityKey, verifiedStatus,
                                                firstUse, timestamp, nonBlockingApproval));
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:20,代码来源:IdentityDatabase.java

示例8: replace

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public boolean replace(SQLiteDatabase database, List<T> ts) {
    try {
        for (T t : ts) {
            database.replace(getTableName(), null, getContentValues(t));
        }
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
        return false;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:BaseDao.java

示例9: setNumber

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void setNumber(ContactTokenDetails token, boolean active) {
  SQLiteDatabase db     = databaseHelper.getWritableDatabase();
  ContentValues  values = new ContentValues();
  values.put(NUMBER, token.getNumber());
  values.put(REGISTERED, active ? 1 : 0);
  values.put(TIMESTAMP, System.currentTimeMillis());
  values.put(RELAY, token.getRelay());
  values.put(VOICE, token.isVoice());
  values.put(VIDEO, token.isVideo());
  db.replace(TABLE_NAME, null, values);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:TextSecureDirectory.java

示例10: saveIdentity

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void saveIdentity(long recipientId, IdentityKey identityKey)
{
  SQLiteDatabase database          = databaseHelper.getWritableDatabase();
  String         identityKeyString = Base64.encodeBytes(identityKey.serialize());

  ContentValues contentValues = new ContentValues();
  contentValues.put(RECIPIENT, recipientId);
  contentValues.put(IDENTITY_KEY, identityKeyString);

  database.replace(TABLE_NAME, null, contentValues);

  context.getContentResolver().notifyChange(CHANGE_URI, null);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:14,代码来源:IdentityDatabase.java

示例11: addDaysOfWeek

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void addDaysOfWeek(Reminder reminder) {
    SQLiteDatabase database = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(COL_ID, reminder.getId());
    values.put(COL_SUNDAY, Boolean.toString(reminder.getDaysOfWeek()[0]));
    values.put(COL_MONDAY, Boolean.toString(reminder.getDaysOfWeek()[1]));
    values.put(COL_TUESDAY, Boolean.toString(reminder.getDaysOfWeek()[2]));
    values.put(COL_WEDNESDAY, Boolean.toString(reminder.getDaysOfWeek()[3]));
    values.put(COL_THURSDAY, Boolean.toString(reminder.getDaysOfWeek()[4]));
    values.put(COL_FRIDAY, Boolean.toString(reminder.getDaysOfWeek()[5]));
    values.put(COL_SATURDAY, Boolean.toString(reminder.getDaysOfWeek()[6]));
    database.replace(DAYS_OF_WEEK_TABLE, null, values);
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:14,代码来源:DatabaseHelper.java

示例12: addColour

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void addColour(Colour colour) {
    SQLiteDatabase database = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(COL_PICKER_COLOUR, colour.getColour());
    values.put(COL_PICKER_DATE_AND_TIME, colour.getDateAndTime());
    database.replace(PICKER_COLOUR_TABLE, null, values);
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:8,代码来源:DatabaseHelper.java

示例13: addAccount

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void addAccount (UserInfo user){
    //获取数据库对象
    SQLiteDatabase db = mHelper.getReadableDatabase();

    //执行添加操作
    ContentValues values = new ContentValues();
    values.put(UserAccountTable.COL_HXID,user.getHxid());
    values.put(UserAccountTable.COL_NAME,user.getName());
    values.put(UserAccountTable.COL_NICK,user.getNick());
    values.put(UserAccountTable.COL_PHOTO,user.getPhoto());

    db.replace(UserAccountTable.TAB_NAME,null,values);
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:14,代码来源:UserAccountDao.java

示例14: updateHubPreferences

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
@Override
public void updateHubPreferences(@NonNull HubPreference... preferences) {
    final SQLiteDatabase db = mDBHelper.getWritableDatabase();

    for (HubPreference preference : preferences) {
        final ContentValues values = new ContentValues();
        values.put("hub_id", preference.getHubId());
        values.put("is_visible", preference.isVisible() ? 1 : 0);
        values.put("_order", preference.getOrder());
        db.replace(PreferenceDBHelper.TABLE_NAME, "hub_id", values);
    }

    db.close();
}
 
开发者ID:nekocode,项目名称:Hubs,代码行数:15,代码来源:PreferenceManager.java

示例15: a

import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public long a(String str, ContentValues contentValues) {
    long j = -1;
    if (this.a == null) {
        c.a("create db fail, lost permission--->android.permission.WRITE_EXTERNAL_STORAGE");
    } else {
        try {
            SQLiteDatabase writableDatabase = this.a.getWritableDatabase();
            c.b("insert database, insert");
            j = writableDatabase.replace(str, null, contentValues);
        } catch (Exception e) {
            c.a("when insert database occur error table:" + str + e.getMessage());
        }
    }
    return j;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:b.java


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