android.content.ContentValues Java Examples

The following examples show how to use android.content.ContentValues. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatabaseHelper.java    From Instagram-Profile-Downloader with MIT License 6 votes vote down vote up
public void insertIntoDb(String username, Bitmap image){
    SQLiteDatabase db = this.getWritableDatabase();

    if(hasObject(username, DB_TABLE))
        deleteRow(username, DB_TABLE);

    try {
        ContentValues contentValues = new ContentValues();
        contentValues.put(USERNAME, username);
        contentValues.put(IMAGE_THUMBNAIL, ZoomstaUtil.getBytes(image));
        db.insert(DB_TABLE, null, contentValues);
        db.close();

    } catch (SQLiteException e){
        e.printStackTrace();
    }

}
 
Example #2
Source File: CourseGateWay.java    From android-apps with MIT License 6 votes vote down vote up
public String updateCourse(Courses aCore) {
	open();
	String msg = "Sorry!! Error for Updating";
	try {
		ContentValues cv = new ContentValues();
		cv.put(DBOpenHelper.COURS_CODE, aCore.getcCode());
		cv.put(DBOpenHelper.COURS_NAME, aCore.getcName());
		cv.put(DBOpenHelper.COURS_DEPT, aCore.getdCode());

		sqLiteDB.update(DBOpenHelper.TABLE_COURS, cv, " "
				+ DBOpenHelper.COURS_CODE + "=" + "'" + aCore.getcCode()
				+ "'", null);

		msg = "Successfully Updated with: " + aCore.getcCode();
	} catch (Exception e) {
		msg = "Sorry!! Error for Updating with: " + aCore.getcCode();
	}
	close();
	return msg;
}
 
Example #3
Source File: LocalImage.java    From medialibrary with Apache License 2.0 6 votes vote down vote up
@Override
public void rotate(int degrees) throws Exception {
    GalleryUtils.assertNotInRenderThread();
    Uri baseUri = Images.Media.EXTERNAL_CONTENT_URI;
    ContentValues values = new ContentValues();
    int rotation = (this.rotation + degrees) % 360;
    if (rotation < 0) rotation += 360;

    if (mimeType.equalsIgnoreCase("image/jpeg")) {
        ExifInterface exifInterface = new ExifInterface(filePath);
        exifInterface.setAttribute(ExifInterface.TAG_ORIENTATION,
                String.valueOf(rotation));
        exifInterface.saveAttributes();
        fileSize = new File(filePath).length();
        values.put(Images.Media.SIZE, fileSize);
    }

    values.put(Images.Media.ORIENTATION, rotation);
    mApplication.getContentResolver().update(baseUri, values, "_id=?",
            new String[]{String.valueOf(id)});
}
 
Example #4
Source File: DataManager.java    From FlipGank with Apache License 2.0 6 votes vote down vote up
private void updateDataDb(List<GankItem> gankItemList, String day) {
    if (gankItemList == null || gankItemList.size() == 0) {
        Log.d(TAG, "updateDataDb return for no data");
        return;
    }

    for (GankItem gankItem: gankItemList) {
        ContentValues item = new ContentValues();
        item.put(GankDbHelper.Contract.COLUMN_ID, gankItem.id);
        item.put(GankDbHelper.Contract.COLUMN_CATEGORY, gankItem.type);
        item.put(GankDbHelper.Contract.COLUMN_DEST, gankItem.desc);
        item.put(GankDbHelper.Contract.COLUMN_DAY, day);
        item.put(GankDbHelper.Contract.COLUMN_URL, gankItem.url);
        item.put(GankDbHelper.Contract.COLUMN_WHO, gankItem.who);
        item.put(GankDbHelper.Contract.COLUMN_IMAGE, gankItem.getImage());
        item.put(GankDbHelper.Contract.COLUMN_LIKE, gankItem.like ? 1 : 0);
        sqLiteDatabase.insert(GankDbHelper.Contract.TABLE_DATA, null, item);
    }
}
 
Example #5
Source File: HobbitProviderImpl.java    From mobilecloud-15 with Apache License 2.0 6 votes vote down vote up
/**
 * Method that handles bulk insert requests.  This method plays
 * the role of the "template method" in the Template Method
 * pattern.
 */
public int bulkInsert(Uri uri,
                      ContentValues[] cvsArray) {
    // Try to match against the path in a url.  It returns the
    // code for the matched node (added using addURI), or -1 if
    // there is no matched node.  If there's a match insert new
    // rows.
    switch (sUriMatcher.match(uri)) {
    case CHARACTERS:
        int returnCount = bulkInsertCharacters(uri,
                                               cvsArray);

        if (returnCount > 0)
            // Notifies registered observers that row(s) were
            // inserted.
            mContext.getContentResolver().notifyChange(uri, 
                                                       null);
        return returnCount;
    default:
        throw new UnsupportedOperationException();
    }
}
 
Example #6
Source File: PutContentValuesStub.java    From storio with Apache License 2.0 6 votes vote down vote up
void verifyBehaviorForMultipleContentValues(@Nullable PutResults<ContentValues> putResults) {
    assertThat(putResults).isNotNull();

    // only one call to storIOSQLite.put() should occur
    verify(storIOSQLite).put();

    // number of calls to putResolver's performPut() should be equal to number of objects
    verify(putResolver, times(contentValues.size())).performPut(eq(storIOSQLite), any(ContentValues.class));

    // each item should be "put"
    for (final ContentValues cv : contentValues) {
        verify(putResolver).performPut(storIOSQLite, cv);
    }

    verifyNotificationsAndTransactionBehavior();
}
 
Example #7
Source File: ChatSessionAdapter.java    From Zom-Android-XMPP with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setGroupChatSubject(String subject) throws RemoteException {
    try {
        if (isGroupChatSession()) {
            ChatGroup group = (ChatGroup)mChatSession.getParticipant();
            getGroupManager().setGroupSubject(group, subject);

            //update the database
            ContentValues values1 = new ContentValues(1);
            values1.put(Imps.Contacts.NICKNAME,subject);
            ContentValues values = values1;

            Uri uriContact = ContentUris.withAppendedId(Imps.Contacts.CONTENT_URI, mContactId);
            mContentResolver.update(uriContact, values, null, null);

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #8
Source File: TodoDetailActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
private void saveState() {
	String category = (String) mCategory.getSelectedItem();
	String summary = mTitleText.getText().toString();
	String description = mBodyText.getText().toString();

	// Only save if either summary or description
	// is available

	if (description.length() == 0 && summary.length() == 0) {
		return;
	}

	ContentValues values = new ContentValues();
	values.put(TodoTable.COLUMN_CATEGORY, category);
	values.put(TodoTable.COLUMN_SUMMARY, summary);
	values.put(TodoTable.COLUMN_DESCRIPTION, description);

	if (todoUri == null) {
		// New todo
		todoUri = getContentResolver().insert(
				MyTodoContentProvider.CONTENT_URI, values);
	} else {
		// Update todo
		getContentResolver().update(todoUri, values, null, null);
	}
}
 
Example #9
Source File: NodeDatabaseHelper.java    From android_packages_apps_GmsCore with Apache License 2.0 6 votes vote down vote up
private static synchronized long getAppKey(SQLiteDatabase db, String packageName, String signatureDigest) {
    Cursor cursor = db.rawQuery("SELECT _id FROM appkeys WHERE packageName=? AND signatureDigest=?", new String[]{packageName, signatureDigest});
    if (cursor != null) {
        try {
            if (cursor.moveToNext()) {
                return cursor.getLong(0);
            }
        } finally {
            cursor.close();
        }
    }
    ContentValues appKey = new ContentValues();
    appKey.put("packageName", packageName);
    appKey.put("signatureDigest", signatureDigest);
    return db.insert("appkeys", null, appKey);
}
 
Example #10
Source File: DatabaseHelper.java    From BackPackTrackII with GNU General Public License v3.0 6 votes vote down vote up
public DatabaseHelper updateSteps(long id, long time, int value) {
    synchronized (mContext.getApplicationContext()) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues cv = new ContentValues();
        cv.put("count", value);
        if (db.update("step", cv, "ID = ?", new String[]{Long.toString(id)}) != 1)
            Log.e(TAG, "Update step failed");
    }

    for (StepCountChangedListener listener : mStepCountChangedListeners)
        try {
            listener.onStepCountUpdated(time, value);
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

    return this;
}
 
Example #11
Source File: FileContentProvider.java    From Cirrus_depricated with GNU General Public License v2.0 6 votes vote down vote up
private void updateFilesTableAccordingToShareInsertion(
        SQLiteDatabase db, ContentValues newShare
) {
    ContentValues fileValues = new ContentValues();
    int newShareType = newShare.getAsInteger(ProviderTableMeta.OCSHARES_SHARE_TYPE);
    if (newShareType == ShareType.PUBLIC_LINK.getValue()) {
        fileValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, 1);
    } else if (
          newShareType == ShareType.USER.getValue() ||
          newShareType == ShareType.GROUP.getValue() ||
          newShareType == ShareType.FEDERATED.getValue() ) {
         fileValues.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, 1);
    }

    String where = ProviderTableMeta.FILE_PATH + "=? AND " +
            ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
    String[] whereArgs = new String[] {
            newShare.getAsString(ProviderTableMeta.OCSHARES_PATH),
            newShare.getAsString(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER)
    };
    db.update(ProviderTableMeta.FILE_TABLE_NAME, fileValues, where, whereArgs);
}
 
Example #12
Source File: DataItemRecord.java    From android_packages_apps_GmsCore with Apache License 2.0 6 votes vote down vote up
public ContentValues toContentValues() {
    ContentValues contentValues = new ContentValues();
    contentValues.put("sourceNode", source);
    contentValues.put("seqId", seqId);
    contentValues.put("v1SourceNode", source);
    contentValues.put("v1SeqId", v1SeqId);
    contentValues.put("timestampMs", lastModified);
    if (deleted) {
        contentValues.put("deleted", 1);
        contentValues.putNull("data");
    } else {
        contentValues.put("deleted", 0);
        contentValues.put("data", dataItem.data);
    }
    contentValues.put("assetsPresent", assetsAreReady ? 1 : 0);
    return contentValues;
}
 
Example #13
Source File: LocalLogSession.java    From nRF-Logger-API with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Creates new logger session. Must be created before appending log entries.
 * If the nRF Logger application is not installed the method will return <code>null</code>.
 * 
 * @param context
 *            the context (activity, service or application)
 * @param authority
 *            the {@link LocalLogContentProvider} authority
 * @param key
 *            the session key, which is used to group sessions
 * @param name
 *            the human readable session name
 * @return the {@link LogContract} that can be used to append log entries or <code>null</code>
 * if MCP is not installed. The <code>null</code> value can be next passed to logging methods
 */
public static LocalLogSession newSession(@NonNull final Context context,
										 @NonNull final Uri authority,
										 @NonNull final String key, @NonNull final String name) {
	final Uri uri = authority.buildUpon()
			.appendEncodedPath(LogContract.Session.SESSION_CONTENT_DIRECTORY)
			.appendEncodedPath(LogContract.Session.KEY_CONTENT_DIRECTORY)
			.appendEncodedPath(key)
			.build();
	final ContentValues values = new ContentValues();
	values.put(LogContract.Session.NAME, name);

	try {
		final Uri sessionUri = context.getContentResolver().insert(uri, values);
		if (sessionUri != null)
			return new LocalLogSession(context, sessionUri);
		return null;
	} catch (final Exception e) {
		Log.e("LocalLogSession", "Error while creating a local log session.", e);
		return null;
	}
}
 
Example #14
Source File: FinalDb.java    From Android-Basics-Codes with Artistic License 2.0 6 votes vote down vote up
/**
 * 保存数据到数据库<br />
 * <b>注意:</b><br />
 * 保存成功后,entity的主键将被赋值(或更新)为数据库的主键, 只针对自增长的id有效
 * 
 * @param entity
 *            要保存的数据
 * @return ture: 保存成功 false:保存失败
 */
public boolean saveBindId(Object entity) {
	checkTableExist(entity.getClass());
	List<KeyValue> entityKvList = SqlBuilder
			.getSaveKeyValueListByEntity(entity);
	if (entityKvList != null && entityKvList.size() > 0) {
		TableInfo tf = TableInfo.get(entity.getClass());
		ContentValues cv = new ContentValues();
		insertContentValues(entityKvList, cv);
		Long id = db.insert(tf.getTableName(), null, cv);
		if (id == -1)
			return false;
		tf.getId().setValue(entity, id);
		return true;
	}
	return false;
}
 
Example #15
Source File: CategoryHandler.java    From opentasks with Apache License 2.0 6 votes vote down vote up
/**
 * Check if a category with matching {@link ContentValues} exists and returns the existing category or creates a new category in the database.
 *
 * @param db
 *         The {@link SQLiteDatabase}.
 * @param values
 *         The {@link ContentValues} of the category.
 *
 * @return The {@link ContentValues} of the existing or new category.
 */
private ContentValues getOrInsertCategory(SQLiteDatabase db, ContentValues values)
{
    if (values.getAsBoolean(IS_NEW_CATEGORY))
    {
        // insert new category in category table
        ContentValues newCategoryValues = new ContentValues(4);
        newCategoryValues.put(Categories.ACCOUNT_NAME, values.getAsString(Categories.ACCOUNT_NAME));
        newCategoryValues.put(Categories.ACCOUNT_TYPE, values.getAsString(Categories.ACCOUNT_TYPE));
        newCategoryValues.put(Categories.NAME, values.getAsString(Category.CATEGORY_NAME));
        newCategoryValues.put(Categories.COLOR, values.getAsInteger(Category.CATEGORY_COLOR));

        long categoryID = db.insert(Tables.CATEGORIES, "", newCategoryValues);
        values.put(Category.CATEGORY_ID, categoryID);
    }

    // remove redundant values
    values.remove(IS_NEW_CATEGORY);
    values.remove(Categories.ACCOUNT_NAME);
    values.remove(Categories.ACCOUNT_TYPE);

    return values;
}
 
Example #16
Source File: WoodminSyncAdapter.java    From Woodmin with Apache License 2.0 6 votes vote down vote up
private void finalizeSyncProducts() {

        /*
        NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(0);
        */

        ContentValues[] productsValuesArray = new ContentValues[productsValues.size()];
        productsValuesArray = productsValues.toArray(productsValuesArray);
        int ordersRowsUpdated = getContext().getContentResolver().bulkInsert(WoodminContract.ProductEntry.CONTENT_URI, productsValuesArray);
        Log.v(LOG_TAG, "Products " + ordersRowsUpdated + " updated");

        /*
        String query = WoodminContract.ProductEntry.COLUMN_ENABLE + " = ?" ;
        String[] parameters = new String[]{ String.valueOf("0") };
        int rowsDeleted = getContext().getContentResolver().delete(WoodminContract.ProductEntry.CONTENT_URI,
                query,
                parameters);
        Log.d(LOG_TAG, "Products: " + rowsDeleted + " old records deleted.");
        */

        getContext().getContentResolver().notifyChange(WoodminContract.ProductEntry.CONTENT_URI, null, false);
        pageProduct = 0;
    }
 
Example #17
Source File: RecentMediaStorage.java    From AndroidTvDemo with Apache License 2.0 5 votes vote down vote up
public void saveUrl(String url)
{
    ContentValues cv = new ContentValues();
    cv.putNull(Entry.COLUMN_NAME_ID);
    cv.put(Entry.COLUMN_NAME_URL, url);
    cv.put(Entry.COLUMN_NAME_LAST_ACCESS, System.currentTimeMillis());
    cv.put(Entry.COLUMN_NAME_NAME, getNameOfUrl(url));
    save(cv);
}
 
Example #18
Source File: SaleDaoAndroid.java    From pos with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void endSale(Sale sale, String endTime) {
	ContentValues content = new ContentValues();
       content.put("_id", sale.getId());
       content.put("status", "ENDED");
       content.put("payment", "n/a");
       content.put("total", sale.getTotal());
       content.put("orders", sale.getOrders());
       content.put("start_time", sale.getStartTime());
       content.put("end_time", endTime);
	database.update(DatabaseContents.TABLE_SALE.toString(), content);
}
 
Example #19
Source File: RemotePreferences.java    From RemotePreferences with MIT License 5 votes vote down vote up
/**
 * Writes multiple preferences at once to the preference provider.
 * If the operation fails and strict mode is enabled, an exception
 * will be thrown; otherwise {@code false} will be returned.
 *
 * @param uri The URI to modify.
 * @param values The values to write.
 * @return Whether the operation succeeded.
 */
private boolean bulkInsert(Uri uri, ContentValues[] values) {
    int count;
    try {
        count = mContext.getContentResolver().bulkInsert(uri, values);
    } catch (Exception e) {
        wrapException(e);
        return false;
    }
    if (count != values.length && mStrictMode) {
        throw new RemotePreferenceAccessException("bulkInsert() failed");
    }
    return count == values.length;
}
 
Example #20
Source File: MediaStoreService.java    From Popeens-DSub with GNU General Public License v3.0 5 votes vote down vote up
public void renameInMediaStore(File start, File end) {
	ContentResolver contentResolver = context.getContentResolver();

	ContentValues values = new ContentValues();
	values.put(MediaStore.MediaColumns.DATA, end.getAbsolutePath());

	int n = contentResolver.update(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
			values,
			MediaStore.MediaColumns.DATA + "=?",
			new String[]{start.getAbsolutePath()});
	if (n > 0) {
		Log.i(TAG, "Rename media store row for " + start + " to " + end);
	}
}
 
Example #21
Source File: BinaryFieldAdapter.java    From opentasks with Apache License 2.0 5 votes vote down vote up
@Override
public void setIn(ContentValues values, byte[] value)
{
    if (value != null)
    {
        values.put(mFieldName, value);
    }
    else
    {
        values.putNull(mFieldName);
    }
}
 
Example #22
Source File: BindArtistsContentProvider.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 *
 * <h2>Supported insert operations</h2>
 * <table>
 * <tr><th>URI</th><th>DAO.METHOD</th></tr>
 * <tr><td><pre>content://com.abubusoft.kripton.example/albums</pre></td><td>{@link AlbumDaoImpl#insert2ForContentProvider}</td></tr>
 * <tr><td><pre>content://com.abubusoft.kripton.example/artists</pre></td><td>{@link ArtistDaoImpl#insert2ForContentProvider}</td></tr>
 * </table>
 *
 */
@Override
public Uri insert(Uri uri, ContentValues contentValues) {
  long _id=-1;
  Uri _returnURL=null;
  switch (sURIMatcher.match(uri)) {
    case PATH_ALBUM_1_INDEX: {
      _id=dataSource.getAlbumDao().insert2ForContentProvider(uri, contentValues);
      _returnURL=Uri.withAppendedPath(uri, String.valueOf(_id));
      break;
    }
    case PATH_ARTIST_3_INDEX: {
      _id=dataSource.getArtistDao().insert2ForContentProvider(uri, contentValues);
      _returnURL=Uri.withAppendedPath(uri, String.valueOf(_id));
      break;
    }
    default: {
      throw new IllegalArgumentException("Unknown URI for INSERT operation: " + uri);
    }
  }
  // log section for content provider insert BEGIN
  if (dataSource.isLogEnabled()) {
    Logger.info("Element is created with URI '%s'", _returnURL);
    Logger.info("Changes are notified for URI '%s'", uri);
  }
  // log section for content provider insert END
  getContext().getContentResolver().notifyChange(uri, null);
  return _returnURL;
}
 
Example #23
Source File: DBHelper.java    From fingen with Apache License 2.0 5 votes vote down vote up
public static ContentValues addSyncDataToCV(ContentValues values, BaseModel baseModel) {
    values.put(DBHelper.C_SYNC_FBID, baseModel.getFBID());
    values.put(DBHelper.C_SYNC_TS, baseModel.getTS());
    values.put(DBHelper.C_SYNC_DELETED, 0);
    values.put(DBHelper.C_SYNC_DIRTY, baseModel.isDirty() ? 1 : 0);
    values.put(DBHelper.C_SYNC_LASTEDITED, baseModel.getLastEdited());
    return values;
}
 
Example #24
Source File: GroupDatabase.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public void remove(@NonNull GroupId groupId, RecipientId source) {
  List<RecipientId> currentMembers = getCurrentMembers(groupId);
  currentMembers.remove(source);

  ContentValues contents = new ContentValues();
  contents.put(MEMBERS, RecipientId.toSerializedList(currentMembers));

  databaseHelper.getWritableDatabase().update(TABLE_NAME, contents, GROUP_ID + " = ?",
                                              new String[] {groupId.toString()});

  RecipientId groupRecipient = DatabaseFactory.getRecipientDatabase(context).getOrInsertFromGroupId(groupId);
  Recipient.live(groupRecipient).refresh();
}
 
Example #25
Source File: Movie.java    From Popular-Movies-App with Apache License 2.0 5 votes vote down vote up
public ContentValues toContentValues() {
    ContentValues values = new ContentValues();
    values.put(MoviesContract.MovieEntry._ID, id);
    values.put(MoviesContract.MovieEntry.COLUMN_ORIGINAL_TITLE, originalTitle);
    values.put(MoviesContract.MovieEntry.COLUMN_OVERVIEW, overview);
    values.put(MoviesContract.MovieEntry.COLUMN_RELEASE_DATE, releaseDate);
    values.put(MoviesContract.MovieEntry.COLUMN_POSTER_PATH, posterPath);
    values.put(MoviesContract.MovieEntry.COLUMN_POPULARITY, popularity);
    values.put(MoviesContract.MovieEntry.COLUMN_TITLE, title);
    values.put(MoviesContract.MovieEntry.COLUMN_AVERAGE_VOTE, averageVote);
    values.put(MoviesContract.MovieEntry.COLUMN_VOTE_COUNT, voteCount);
    values.put(MoviesContract.MovieEntry.COLUMN_BACKDROP_PATH, backdropPath);
    return values;
}
 
Example #26
Source File: StartDatedTest.java    From opentasks with Apache License 2.0 5 votes vote down vote up
@Test
public void testNone()
{
    ContentValues instanceData = new StartDated(absent(), ContentValues::new).value();

    assertThat(instanceData, new ContentValuesWithLong(TaskContract.Instances.INSTANCE_START, nullValue(Long.class)));
    assertThat(instanceData, new ContentValuesWithLong(TaskContract.Instances.INSTANCE_START_SORTING, nullValue(Long.class)));
    // this doesn't actually add anything, the ContentValues are expected to contain null values.
    assertThat(instanceData.size(), is(0));
}
 
Example #27
Source File: TestContentProviderCase1Runtime.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * Insert rows.
 *
 * @param rows the rows
 */
private void insertRows(int rows) {
	ContentValues contentValues = new ContentValues();
					
	for (int i = 0; i < rows; i++) {
		Uri uri = BindArtistsContentProvider.URI_ARTIST_INSERT;
		contentValues.put(ArtistTable.COLUMN_NAME, "Tonj Manero"+i);
		Uri resultURI = getApplicationContext().getContentResolver().insert(uri, contentValues);
		assertTrue(Long.parseLong(resultURI.toString().replace(BindArtistsContentProvider.URI_ARTIST_INSERT+"/", "")) > 0);
	}
}
 
Example #28
Source File: SamsungHomeBadger.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
private ContentValues getContentValues(ComponentName componentName, int badgeCount, boolean isInsert) {
    ContentValues contentValues = new ContentValues();
    if (isInsert) {
        contentValues.put("package", componentName.getPackageName());
        contentValues.put("class", componentName.getClassName());
    }

    contentValues.put("badgecount", badgeCount);

    return contentValues;
}
 
Example #29
Source File: GroupDBTask.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static void update(GroupListBean bean, String accountId) {

        if (bean == null || bean.getLists().size() == 0) {
            return;
        }

        clearGroup(accountId);

        ContentValues cv = new ContentValues();
        cv.put(GroupTable.ACCOUNTID, accountId);
        cv.put(GroupTable.JSONDATA, new Gson().toJson(bean));
        getWsd().insert(GroupTable.TABLE_NAME, HomeTable.ID, cv);

    }
 
Example #30
Source File: SqliteHelper.java    From SqliteManager with Apache License 2.0 5 votes vote down vote up
public void addContact(Contact contact) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(CONTACT_KEY_ID, contact.getId()); // Contact Name
    values.put(CONTACT_KEY_NAME, contact.getName()); // Contact Name
    values.put(CONTACT_KEY_ADDR, contact.getAddress()); // Contact Phone Number

    // Inserting Row
    db.insert(TABLE_CONTACTS, null, values);
    db.close(); // Closing database connection
}