Android DatabaseUtils.InsertHelper - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DatabaseUtils.InsertHelper class.

This code example shows how to use the following methods:getColumnIndex
		onCreate(db);
	} 
 
	private void insertConsoles(SQLiteDatabase db) {
		// Create a single InsertHelper to handle this set of insertions. 
        InsertHelper ih = new InsertHelper(db, "consoles");
         
        // Get the numeric indexes for each of the columns that we're updating. 
        final int nameColumn = ih.getColumnIndex("console_name");
        final int aliasColumn = ih.getColumnIndex("console_alias");
        final int categoryColumn = ih.getColumnIndex("category");
         
        // Insert Nintendo consoles. 
        ih.prepareForInsert();
        ih.bind(nameColumn, "Nintendo NES"); ih.bind(aliasColumn, "nes"); ih.bind(categoryColumn, 1);
         
        ih.execute(); ih.prepareForInsert();
        ih.bind(nameColumn, "Super Nintendo"); ih.bind(aliasColumn, "super-nintendo"); ih.bind(categoryColumn, 1);
         
        ih.execute(); ih.prepareForInsert();
5
CodeRank
This code example shows how to use the following methods:insert
    } 
 
    @Override 
    public long insert(ContentValues values) {
        Set<String> packagesModified = getModifiedPackages(values);
        long rowId = mInsertHelper.insert(values);
        if (rowId > 0 && packagesModified.size() != 0) {
            notifyVoicemailChangeOnInsert( 
                    ContentUris.withAppendedId(mBaseUri, rowId), packagesModified);
        } 
        if (rowId > 0 && mIsCallsTable) {
            notifyCallLogChange(); 
        } 
        return rowId;
    } 
 
    private void notifyCallLogChange() { 
        mContext.getContentResolver().notifyChange(Calls.CONTENT_URI, null, false);
    } 
 
6
CodeRank
This code example shows how to use the following methods:getColumnIndex
 
	@Override 
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		if(oldVersion < 2) {
			// Add a few new consoles. 
			InsertHelper ih = new InsertHelper(db, "consoles");
			final int id = ih.getColumnIndex(_ID);
	        final int name = ih.getColumnIndex("console_name");
	        final int abbv = ih.getColumnIndex("console_abbv");	 
	         
	        ih.prepareForInsert(); ih.bind(id, 190); ih.bind(name, "Sord M5"); ih.bind(abbv, "Sord"); ih.execute();
	        ih.prepareForInsert(); ih.bind(id, 191); ih.bind(name, "Oric-1 / Atmos"); ih.bind(abbv, "Oric"); ih.execute();
	        ih.prepareForInsert(); ih.bind(id, 192); ih.bind(name, "Acorn Archimedes"); ih.bind(abbv, "Arch"); ih.execute();
	        ih.prepareForInsert(); ih.bind(id, 193); ih.bind(name, "Panasonic JR"); ih.bind(abbv, "JR"); ih.execute();
	        ih.prepareForInsert(); ih.bind(id, 194); ih.bind(name, "Steam"); ih.bind(abbv, "Steam"); ih.execute();
		} 
	} 
	 
	private void insertConsoles(SQLiteDatabase db) {
		// Create a single InsertHelper to handle this set of insertions. 
5
CodeRank
This code example shows how to use the following methods:getColumnIndex
	 * @param dishes 
	 *     {@link List} �� �������� {@link Dish} 
	 */ 
	public void addMenu(int date, List<Dish> dishes) {
		ContentValues data = new ContentValues();
		InsertHelper ih = new InsertHelper(mDb, DB_TABLE_MENU);
 
		final int muDateI = ih.getColumnIndex(MENU_DATE_NAME);
		final int muDishIdI = ih.getColumnIndex(MENU_DISH_ID_NAME);
		final int muAvalamI = ih.getColumnIndex(MENU_AVALAM_NAME);
		final int muOrderamI = ih.getColumnIndex(MENU_ORDERAM_NAME);
		 
		date = date - (date % 86400);
	 
		mDb.beginTransaction();
		try { 
			for (int i = 0; i < dishes.size(); i++) {
				Cursor c = mDb.query(false, DB_TABLE_DISHES, new String[] {DISHES_NAME_NAME},
						KEY_ID + " = ?", new String[] {Integer.toString(dishes.get(i).getId())}, null,
						null, null, null); 
5
CodeRank
This code example shows how to use the following methods:getColumnIndex
	 * @param dishes 
	 *     {@link List} �� �������� {@link Dish} 
	 */ 
	public void addMenu(int date, List<Dish> dishes) {
		ContentValues data = new ContentValues();
		InsertHelper ih = new InsertHelper(mDb, DB_TABLE_MENU);
 
		final int muDateI = ih.getColumnIndex(MENU_DATE_NAME);
		final int muDishIdI = ih.getColumnIndex(MENU_DISH_ID_NAME);
		final int muAvalamI = ih.getColumnIndex(MENU_AVALAM_NAME);
		final int muOrderamI = ih.getColumnIndex(MENU_ORDERAM_NAME);
		 
		date = date - (date % 86400);
	 
		mDb.beginTransaction();
		try { 
			for (int i = 0; i < dishes.size(); i++) {
				Cursor c = mDb.query(false, DB_TABLE_DISHES, new String[] {DISHES_NAME_NAME},
						KEY_ID + " = ?", new String[] {Integer.toString(dishes.get(i).getId())}, null,
						null, null, null); 
5
CodeRank
This code example shows how to use the following methods:getColumnIndex
	 * @param dishes 
	 *     {@link List} �� �������� {@link Dish} 
	 */ 
	public void addMenu(int date, List<Dish> dishes) {
		ContentValues data = new ContentValues();
		InsertHelper ih = new InsertHelper(mDb, DB_TABLE_MENU);
 
		final int muDateI = ih.getColumnIndex(MENU_DATE_NAME);
		final int muDishIdI = ih.getColumnIndex(MENU_DISH_ID_NAME);
		final int muAvalamI = ih.getColumnIndex(MENU_AVALAM_NAME);
		final int muOrderamI = ih.getColumnIndex(MENU_ORDERAM_NAME);
		 
		date = date - (date % 86400);
	 
		mDb.beginTransaction();
		try { 
			for (int i = 0; i < dishes.size(); i++) {
				Cursor c = mDb.query(false, DB_TABLE_DISHES, new String[] {DISHES_NAME_NAME},
						KEY_ID + " = ?", new String[] {Integer.toString(dishes.get(i).getId())}, null,
						null, null, null); 
5
CodeRank
This code example shows how to use the following methods:getColumnIndex
This code example shows how to use the following methods:insert
		if (dbHelper.getWritableDatabase().isDbLockedByOtherThreads()) {
			Log.v(TAG, "Database was locked by another thread");
			return -1; 
		} 
		 
		return insertHelper.insert(values);
	} 
 
	public int getSensorsBufferSize() { 
		return sensorsBufferSize;
	} 
 
	public void setSensorsBufferSize(int sensorsBufferSize) {
		this.sensorsBufferSize = sensorsBufferSize;
	} 
 
	public int getDatabaseLockWaitTime() { 
		return databaseLockWaitTime;
	} 
 
5
CodeRank
This code example shows how to use the following methods:insert
    } 
 
    @Override 
    public long insert(ContentValues values) {
        Set<String> packagesModified = getModifiedPackages(values);
        long rowId = mInsertHelper.insert(values);
        if (rowId > 0 && packagesModified.size() != 0) {
            notifyVoicemailChangeOnInsert( 
                    ContentUris.withAppendedId(mBaseUri, rowId), packagesModified);
        } 
//        if (rowId > 0 && mIsCallsTable) {     // Do not notify for insert operation 
//            notifyCallLogChange(); 
//        } 
        return rowId;
    } 
 
    private void notifyCallLogChange() { 
        mContext.getContentResolver().notifyChange(Calls.CONTENT_URI, null, false);
    } 
 
3
CodeRank

Related Android DatabaseUtils.InsertHelper Questions & Answers:

See Code Examples for Android DatabaseUtils.InsertHelper Methods: