vendredi 5 juin 2015

Troubles with bulckInsert sqlite

here is my code:

@Override
    public int bulkInsert(Uri uri, ContentValues[] values) {
        final SQLiteDatabase db = mDbHelper.getWritableDatabase();
        final int match = sUriMatcher.match(uri);
        int returnCount = 0;
        switch (match){
            case USER_PROFILE_INFORMATION:
                db.beginTransaction();
                try {
                    for (ContentValues value : values){
                        long _id = db.insert(UserProfileInfoEntry.TABLE_NAME, null, value);
                        if (_id != -1){
                            returnCount++;
                        }
                    }
                    db.setTransactionSuccessful();
                } finally {
                    db.endTransaction();
                }
                getContext().getContentResolver().notifyChange(uri, null);
                return returnCount;

            default:
                return super.bulkInsert(uri, values);
        }
    }

but i got problem...

long _id = db.insert(UserProfileInfoEntry.TABLE_NAME, null, value);

it return _id = -1 and because of this nothing insert into my database...

will be glad any help!

Aucun commentaire:

Enregistrer un commentaire