public void addItemBookmark(ItemBookmark item) {
   SQLiteDatabase db = this.getWritableDatabase();
   ContentValues cv = item.getContentValues();
   db.insertWithOnConflict(
       ITEMS_TABLE_BOOKMARK, null, item.getContentValues(), SQLiteDatabase.CONFLICT_REPLACE);
   db.close();
 }
  /** @param characterInfo */
  public void setCharacterSheet(CharacterSheetResponse characterSheet) {
    ContentValues insertValues = new ContentValues();

    insertValues.put(COL_CHARACTER_ID, characterSheet.getCharacterID());
    insertValues.put(COL_NAME, characterSheet.getName());
    // insertValues.put(COL_RACE, characterSheet.getRace().name()); TODO figure out why eve race
    // breaks
    insertValues.put(COL_DOB, formatter.format(characterSheet.getDateOfBirth()));
    insertValues.put(COL_BLOODLINE, characterSheet.getBloodLine().name());
    insertValues.put(COL_ANCESTRY, characterSheet.getAncestry().name());
    insertValues.put(COL_GENDER, characterSheet.getGender());
    insertValues.put(COL_CORP_NAME, characterSheet.getCorporationName());
    insertValues.put(COL_CORP_ID, characterSheet.getCorporationID());
    insertValues.put(COL_ALLIANCE_ID, characterSheet.getAllianceID());
    insertValues.put(COL_ALLIANCE, characterSheet.getAllianceName());
    insertValues.put(COL_CLONE_NAME, characterSheet.getCloneName());
    insertValues.put(COL_CLONE_SP, characterSheet.getCloneSkillPoints());
    insertValues.put(COL_BALANCE, characterSheet.getBalance());

    insertValues.put(COL_INTELLIGENCE, characterSheet.getIntelligence());
    insertValues.put(COL_MEMORY, characterSheet.getMemory());
    insertValues.put(COL_CHARISMA, characterSheet.getCharisma());
    insertValues.put(COL_PERCEPTION, characterSheet.getPerception());
    insertValues.put(COL_WILLPOWER, characterSheet.getWillpower());

    db.insertWithOnConflict(TABLE, null, insertValues, SQLiteDatabase.CONFLICT_REPLACE);
  }
Exemplo n.º 3
0
 public long insertQuestionnaire_Field_Association(
     DatabaseOperations dop,
     String questionnaire_id,
     int field_id,
     String required,
     String field_type,
     String option_value,
     int order) {
   try {
     SQLiteDatabase SQ = dop.getWritableDatabase();
     ContentValues cv = new ContentValues();
     cv.put(Table_Info_Questionnaire_Field_Association.QUESTIONNAIRE_ID, questionnaire_id);
     cv.put(Table_Info_Questionnaire_Field_Association.FIELD_ID, field_id);
     cv.put(Table_Info_Questionnaire_Field_Association.REQUIRED, required);
     cv.put(Table_Info_Questionnaire_Field_Association.FIELD_TYPE, field_type);
     cv.put(Table_Info_Questionnaire_Field_Association.OPTION_VALUE, option_value);
     cv.put(Table_Info_Questionnaire_Field_Association.ORDER, order);
     long k =
         SQ.insertWithOnConflict(
             Table_Info_Questionnaire_Field_Association.TABLE_NAME,
             null,
             cv,
             SQLiteDatabase.CONFLICT_REPLACE);
     Log.d("database operation", "one row inserted");
     return k;
   } catch (Exception ex) {
     return -1;
   }
 }
  @Override
  public void onCreate(SQLiteDatabase db) {
    // create table
    String sqlQuery =
        String.format(
            "CREATE TABLE %s (_id INTEGER PRIMARY KEY AUTOINCREMENT, %s TEXT, %s TEXT)",
            AnswersDatabase.TABLE,
            AnswersDatabase.Columns.QUESTION,
            AnswersDatabase.Columns.ANSWERS);
    db.execSQL(sqlQuery);

    // insert values
    ContentValues values = new ContentValues();
    values.clear();
    for (Questions question : Questions.values()) {
      Log.d(
          "AnswersDatabaseHelper",
          "inserting: " + question.getQuestionText() + ": " + question.getPossibleAnswers());
      values.put(AnswersDatabase.Columns.QUESTION, question.getQuestionText());
      values.put(AnswersDatabase.Columns.ANSWERS, question.getPossibleAnswers());
      db.insertWithOnConflict(AnswersDatabase.TABLE, null, values, SQLiteDatabase.CONFLICT_IGNORE);
    }

    Log.d(
        "MainActivity",
        "Number of entries in database: "
            + DatabaseUtils.queryNumEntries(db, AnswersDatabase.TABLE));
    Log.d("AnswersDatabaseHelper", "creating answers table; pre-populating with answers");
  }
Exemplo n.º 5
0
 @Override
 public int bulkInsert(Uri uri, ContentValues[] values) {
   SQLiteDatabase db = mOpenHelper.getWritableDatabase();
   switch (match_uri(uri)) {
     case MATCHES:
       db.beginTransaction();
       int returncount = 0;
       try {
         for (ContentValues value : values) {
           long _id =
               db.insertWithOnConflict(
                   DatabaseContract.SCORES_TABLE, null, value, SQLiteDatabase.CONFLICT_REPLACE);
           if (_id != -1) {
             returncount++;
           }
         }
         db.setTransactionSuccessful();
       } finally {
         db.endTransaction();
       }
       getContext().getContentResolver().notifyChange(uri, null);
       return returncount;
     default:
       return super.bulkInsert(uri, values);
   }
 }
 @NonNull
 @Override
 public NotificationListWithCount bulkInsert(
     @NonNull SQLiteDatabase writableDb, @NonNull Uri uri, @NonNull ContentValues[] values) {
   switch (uriMatcher.match(uri)) {
     case PRODUCTION_COMPANIES:
       writableDb.beginTransaction();
       int returnCount = 0;
       long insertedId;
       try {
         for (ContentValues value : values) {
           if (value == null || value.getAsLong(ProductionCompanyContract._ID) == null) {
             continue;
           }
           insertedId =
               writableDb.insertWithOnConflict(
                   ProductionCompanyContract.TABLE_NAME,
                   null,
                   value,
                   INDEX_INSERT_RESOLVE_CONFLICT_REPLACE);
           if (insertedId > 0) {
             returnCount++;
           }
         }
         writableDb.setTransactionSuccessful();
       } finally {
         writableDb.endTransaction();
       }
       return new NotificationListWithCount(Collections.singleton(uri), returnCount);
     default:
       throw new UnsupportedOperationException("Unknown uri: " + uri);
   }
 }
Exemplo n.º 7
0
 public long insertSurveyQuestion(
     DatabaseOperations dop,
     String questionID,
     String uniquecode,
     String creationdate,
     String lastupdate,
     String questionnaireID,
     String status,
     String required,
     String other,
     String question_type,
     String field_type,
     String question,
     String option1,
     String option2,
     String option3,
     String option4,
     String option5,
     String option6,
     String option7,
     String option8,
     String option9,
     int display_order) {
   try {
     question_type = question_type.replace("'", "''");
     question = question.replace("'", "''");
     field_type = field_type.replace("'", "''");
     SQLiteDatabase SQ = dop.getWritableDatabase();
     ContentValues cv = new ContentValues();
     cv.put(TableInfo_Survey_Question.QUESTION_ID, questionID);
     cv.put(TableInfo_Survey_Question.UNIQUE_CODE, uniquecode);
     cv.put(TableInfo_Survey_Question.CREATION_DATE, creationdate);
     cv.put(TableInfo_Survey_Question.LAST_UPDATE, lastupdate);
     cv.put(TableInfo_Survey_Question.QUESTIONNAIRE_ID, questionnaireID);
     cv.put(TableInfo_Survey_Question.STATUS, status);
     cv.put(TableInfo_Survey_Question.REQUIRED, required);
     cv.put(TableInfo_Survey_Question.OTHER, other);
     cv.put(TableInfo_Survey_Question.QUESTION_TYPE, question_type);
     cv.put(TableInfo_Survey_Question.FIELD_TYPE, field_type);
     cv.put(TableInfo_Survey_Question.QUESTION, question);
     cv.put(TableInfo_Survey_Question.OPTION1, option1);
     cv.put(TableInfo_Survey_Question.OPTION2, option2);
     cv.put(TableInfo_Survey_Question.OPTION3, option3);
     cv.put(TableInfo_Survey_Question.OPTION4, option4);
     cv.put(TableInfo_Survey_Question.OPTION5, option5);
     cv.put(TableInfo_Survey_Question.OPTION6, option6);
     cv.put(TableInfo_Survey_Question.OPTION7, option7);
     cv.put(TableInfo_Survey_Question.OPTION8, option8);
     cv.put(TableInfo_Survey_Question.OPTION9, option9);
     cv.put(TableInfo_Survey_Question.DISPLAY_ORDER, display_order);
     long k =
         SQ.insertWithOnConflict(
             TableInfo_Survey_Question.TABLE_NAME, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
     Log.d("database operation", "one row inserted");
     return k;
   } catch (Exception ex) {
     return -1;
   }
 }
Exemplo n.º 8
0
  private long putThumbnail(SQLiteDatabase db, Thumbnail thumbnail, int userId) {
    ContentValues values = new ContentValues();
    values.put(ThumbnailTable.COLUMN_USER_ID, userId);
    values.put(ThumbnailTable.COLUMN_HREF, thumbnail.href);
    values.put(ThumbnailTable.COLUMN_SIZE, thumbnail.size);

    return db.insertWithOnConflict(
        ThumbnailTable.NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
  }
  public void insert(String table, long timestamp, double value) {
    database = dbHelper.getWritableDatabase();

    ContentValues values = getAsContentVaues(timestamp, value);

    database.insertWithOnConflict(table, null, values, SQLiteDatabase.CONFLICT_IGNORE);

    Log.d(TAG, "insert into " + table + " values (" + timestamp + ", " + value + ")");
  }
Exemplo n.º 10
0
 public void insertOrIgnore(ContentValues values) {
   Log.d(TAG, "insertOrIgnore on " + values);
   SQLiteDatabase db = this.dbHelper.getWritableDatabase();
   try {
     db.insertWithOnConflict(TABLE, null, values, SQLiteDatabase.CONFLICT_IGNORE);
   } finally {
     db.close(); //
   }
 }
Exemplo n.º 11
0
  public void addBorrowedEntry(String title, String dueDate) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(KEY_TITLE, title);
    values.put(KEY_DUE_DATE, dueDate);

    db.insertWithOnConflict(TABLE_BORROWED, null, values, SQLiteDatabase.CONFLICT_REPLACE);

    db.close();
  }
Exemplo n.º 12
0
  private long putLink(SQLiteDatabase db, Link link, String statusId) {
    ContentValues values = new ContentValues();
    values.put(LinkTable.COLUMN_STATUS_ID, statusId);
    values.put(LinkTable.COLUMN_REL, link.rel);
    values.put(LinkTable.COLUMN_HREF, link.href);
    values.put(LinkTable.COLUMN_NAME, link.name);
    values.put(LinkTable.COLUMN_PERMALINK, link.permalink);

    return db.insertWithOnConflict(LinkTable.NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);
  }
  @Test
  public void testInsertKeyGeneration() throws Exception {
    ContentValues values = new ContentValues();
    values.put("name", "Chuck");

    long key =
        database.insertWithOnConflict("table_name", null, values, SQLiteDatabase.CONFLICT_IGNORE);

    assertThat(key).isNotEqualTo(0L);
  }
Exemplo n.º 14
0
  /**
   * Inserts into database
   *
   * @param values Name/value pairs data
   */
  public void insert(ContentValues values) {
    // Open Database
    SQLiteDatabase db = dbHelper.getWritableDatabase();

    // Insert into database
    db.insertWithOnConflict(DbHelper.TABLE, null, values, SQLiteDatabase.CONFLICT_IGNORE);

    // Close Database
    db.close();
    // dbHelper.close();
  }
Exemplo n.º 15
0
  public synchronized long putAppUser(User appUser) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(AppUserTable.COLUMN_ID, appUser.id);

    long id =
        db.insertWithOnConflict(AppUserTable.NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);

    db.close();

    return id;
  }
Exemplo n.º 16
0
 public long insertFieldTable(DatabaseOperations dop, String field_name) {
   try {
     SQLiteDatabase SQ = dop.getWritableDatabase();
     ContentValues cv = new ContentValues();
     cv.put(Table_Info_Field_Table.FIELD_NAME, field_name);
     long k =
         SQ.insertWithOnConflict(
             Table_Info_Field_Table.TABLE_NAME, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
     Log.d("database operation", "one row inserted");
     return k;
   } catch (Exception ex) {
     return -1;
   }
 }
Exemplo n.º 17
0
 public synchronized Uri insert(Uri uri, ContentValues contentValues) {
   long insertWithOnConflict;
   int match = f2392b.match(uri);
   SQLiteDatabase writableDatabase = this.f2393c.getWritableDatabase();
   switch (match) {
     case C1128R.styleable.StickyListHeadersListView_android_padding /*1*/:
       insertWithOnConflict =
           writableDatabase.insertWithOnConflict("sticker_packs_table", null, contentValues, 4);
       getContext().getContentResolver().notifyChange(uri, null);
       break;
     default:
       throw new IllegalArgumentException("Unknown URI: " + uri);
   }
   return Uri.parse("sticker_packs_table/" + insertWithOnConflict);
 }
Exemplo n.º 18
0
 /** New attachment insertion */
 public Attachment updateAttachment(long noteId, Attachment attachment, SQLiteDatabase db) {
   ContentValues valuesAttachments = new ContentValues();
   valuesAttachments.put(
       KEY_ATTACHMENT_ID,
       attachment.getId() != null ? attachment.getId() : Calendar.getInstance().getTimeInMillis());
   valuesAttachments.put(KEY_ATTACHMENT_NOTE_ID, noteId);
   valuesAttachments.put(KEY_ATTACHMENT_URI, attachment.getUri().toString());
   valuesAttachments.put(KEY_ATTACHMENT_MIME_TYPE, attachment.getMime_type());
   valuesAttachments.put(KEY_ATTACHMENT_NAME, attachment.getName());
   valuesAttachments.put(KEY_ATTACHMENT_SIZE, attachment.getSize());
   valuesAttachments.put(KEY_ATTACHMENT_LENGTH, attachment.getLength());
   db.insertWithOnConflict(
       TABLE_ATTACHMENTS, KEY_ATTACHMENT_ID, valuesAttachments, SQLiteDatabase.CONFLICT_REPLACE);
   return attachment;
 }
Exemplo n.º 19
0
  @Override
  public Uri insert(Uri uri, ContentValues initialValues) {
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();

    switch (sUriMatcher.match(uri)) {
      case API_KEY_ID:
        db.insertWithOnConflict(
            ApiKey.TABLE_NAME, null, initialValues, SQLiteDatabase.CONFLICT_REPLACE);

        return uri;

      case CHARACTERS_ID:
        db.insertWithOnConflict(
            Character.TABLE_NAME, null, initialValues, SQLiteDatabase.CONFLICT_REPLACE);

        return uri;

      case CORP_ID:
        db.insertWithOnConflict(
            ColumnsNames.Corporation.TABLE_NAME,
            null,
            initialValues,
            SQLiteDatabase.CONFLICT_REPLACE);

        return uri;

      case SKILL_ID:
        db.insertWithOnConflict(
            ColumnsNames.Skill.TABLE_NAME, null, initialValues, SQLiteDatabase.CONFLICT_REPLACE);

        return uri;

      default:
        throw new IllegalArgumentException("Unknown URI " + uri);
    }
  }
Exemplo n.º 20
0
  private long putUser(SQLiteDatabase db, User user) {
    ContentValues values = new ContentValues();
    values.put(UserTable.COLUMN_ID, user.id);
    values.put(UserTable.COLUMN_FIRST_NAME, user.first_name);
    values.put(UserTable.COLUMN_LAST_NAME, user.last_name);

    long id =
        db.insertWithOnConflict(UserTable.NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);

    // putting thumbnails datas
    for (Thumbnail thumbnail : user.thumbnails) {
      putThumbnail(db, thumbnail, user.id);
    }

    return id;
  }
  private void getMms() {

    final String[] projection = new String[] {"_id", "ct_t"};
    Uri uri = Uri.parse("content://mms/");
    cursorGetMms = getContentResolver().query(uri, projection, null, null, null);
    while (cursorGetMms.moveToNext()) {
      String string = cursorGetMms.getString(cursorGetMms.getColumnIndex("ct_t"));

      if ("application/vnd.wap.multipart.related".equals(string)) {

        mmsId = cursorGetMms.getString(cursorGetMms.getColumnIndex(Telephony.MmsSms._ID));
        i = Integer.decode(mmsId);

        String selection = "_id = " + mmsId;

        Cursor cursor = getContentResolver().query(mmsUri, null, selection, null, null);

        getMmsContentType();

        cursor.close();
      }

      if (mmsBody != null) {
        mmsType = 1;
        if (mmsImage != null) {
          mmsType = 3;
        }
      } else if (mmsImage != null) {
        mmsType = 2;
      }

      valuesMms.put(DataBaseHelper.mmsID, mmsId);
      valuesMms.put(DataBaseHelper.mmsLQID, i);
      valuesMms.put(DataBaseHelper.mmsDate, mmsDate);
      valuesMms.put(DataBaseHelper.mmsThreadID, mmsThreadID);
      valuesMms.put(DataBaseHelper.mmsMessage, mmsBody);
      valuesMms.put(DataBaseHelper.mmsPicture, mmsImage);
      valuesMms.put(DataBaseHelper.mmsType, mmsType);
      valuesMms.put(DataBaseHelper.mmsName, mmsName);
      valuesMms.put(DataBaseHelper.mmsNumber, mmsNumber);

      contactDb.insertWithOnConflict(
          DataBaseHelper.tableMms, null, valuesMms, SQLiteDatabase.CONFLICT_REPLACE);
      Log.e("MMS : ", "Value Added");
    }
    cursorGetMms.close();
  }
  @Override
  public Uri insert(Uri uri, ContentValues contentValues) {
    int uriType = ContentDescriptor.uriMatcher.match(uri);
    String tableName = ContentDescriptor.getTableName(uriType);

    SQLiteDatabase db = dbHelper.getWritableDatabase();
    long id =
        db.insertWithOnConflict(tableName, null, contentValues, SQLiteDatabase.CONFLICT_IGNORE);

    getContext().getContentResolver().notifyChange(uri, null);

    if (TextUtils.equals(tableName, ContentDescriptor.Toys.TABLE_NAME)) {
      return Uri.parse(ContentDescriptor.Toys.TABLE_URI + "/" + id);
    } else {
      return null;
    }
  }
  @Override
  public ContentValues saveDepartamento(ContentValues departamentoContentValue) {
    try {
      SQLiteDatabase sqLiteDatabase = accessorSQLiteOpenHelper.getWritableDatabase();

      long rowId =
          sqLiteDatabase.insertWithOnConflict(
              DepartamentoContract.TABLE_NAME,
              null,
              departamentoContentValue,
              SQLiteDatabase.CONFLICT_IGNORE);
      return ((rowId != -1L) ? departamentoContentValue : null);
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
Exemplo n.º 24
0
  @Override
  public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] valuesArray) {
    int match = uriMatcher.match(uri);
    String table;
    switch (match) {
      case ALL_ROWS:
        table = uri.getLastPathSegment();
        break;
      case ROW_BY_ID:
        throw new UnsupportedOperationException("Unable to insert by id for uri: " + uri);
      default:
        throw new UnsupportedOperationException("Unknown uri: " + uri);
    }

    SQLiteDatabase db = dbHelper.getWritableDatabase();

    int count = 0;
    db.acquireReference();
    try {
      startTransaction(db);
      try {
        final String nullColumnHack = getNullColumnHack(table);
        final int conflictAlgorithm = getConflictAlgorithm(table);

        for (ContentValues values : valuesArray) {
          long id = db.insertWithOnConflict(table, nullColumnHack, values, conflictAlgorithm);
          if (id != -1) {
            ++count;
          }
        }
        db.setTransactionSuccessful();
      } finally {
        db.endTransaction();
      }
    } finally {
      db.releaseReference();
    }

    // notify change essentially indicates to any users with active cursors
    // that they need to "reload" the data
    if (count > 0) {
      notifyChange(uri);
    }
    return count;
  }
Exemplo n.º 25
0
  public long insertSurveyAnswer(
      DatabaseOperations dop,
      String uniqueUserId,
      String questionnaireID,
      String questionID,
      String question_type,
      String answer,
      String required,
      String field_name,
      String field_value,
      String field_type,
      String field_required,
      String image_Qid,
      String image_question_type,
      String image_question_required,
      String imagearray) {
    try {
      field_name = field_name.replace("'", "''");

      SQLiteDatabase SQ = dop.getWritableDatabase();
      ContentValues cv = new ContentValues();
      cv.put(TableInfo_Survey_Answer.UNIQUE_USER_ID, uniqueUserId);
      cv.put(TableInfo_Survey_Answer.QUESTIONNAIRE_ID, questionnaireID);
      cv.put(TableInfo_Survey_Answer.QUESTION_ID, questionID);
      cv.put(TableInfo_Survey_Answer.QUESTION_TYPE, question_type);
      cv.put(TableInfo_Survey_Answer.ANSWER, answer);
      cv.put(TableInfo_Survey_Answer.REQUIRED, required);
      cv.put(TableInfo_Survey_Answer.FIELD_NAME, field_name);
      cv.put(TableInfo_Survey_Answer.FIELD_VALUE, field_value);
      cv.put(TableInfo_Survey_Answer.FIELD_TYPE, field_type);
      cv.put(TableInfo_Survey_Answer.FIELD_REQUIRED, field_required);
      cv.put(TableInfo_Survey_Answer.IMAGE_QID, image_Qid);
      cv.put(TableInfo_Survey_Answer.IMAGE_QUESTION_TYPE, image_question_type);
      cv.put(TableInfo_Survey_Answer.IMAGE_QUESTION_REQUIRED, image_question_required);
      cv.put(TableInfo_Survey_Answer.IMAGE_ARRAY, imagearray);
      long k =
          SQ.insertWithOnConflict(
              TableInfo_Survey_Answer.TABLE_NAME, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
      Log.d("database operation", "one row inserted");
      return k;
    } catch (Exception ex) {
      return -1;
    }
  }
Exemplo n.º 26
0
  private void createRow(Product p) {
    ContentValues values = new ContentValues();
    values.put(SHOPPINGLIST_PRODUCT, p.getId());
    // Log.v(TAG, values.getAsString(SHOPPINGLIST_PRODUCT));
    long insertId =
        database.insertWithOnConflict(
            TABLE_SHOPPINGLIST, null, values, SQLiteDatabase.CONFLICT_REPLACE);

    if (insertId == -1) {
      Log.v(TAG, "Saving Product to shopping list database failed. Product: " + p.getName());
    } else {
      Log.v(
          TAG,
          "Saved Product to shopping list database. Insert ID: "
              + insertId
              + " Product: "
              + p.getName());
    }
  }
Exemplo n.º 27
0
  @Override
  public Uri insert(@NonNull Uri uri, ContentValues values) {
    int match = uriMatcher.match(uri);
    String table;
    switch (match) {
      case ALL_ROWS:
        table = uri.getLastPathSegment();
        break;
      case ROW_BY_ID:
        throw new UnsupportedOperationException("Unable to insert by id for uri: " + uri);
      default:
        throw new UnsupportedOperationException("Unknown uri: " + uri);
    }

    long id = -1;

    SQLiteDatabase db = dbHelper.getWritableDatabase();
    db.acquireReference();
    try {
      startTransaction(db);
      try {
        id =
            db.insertWithOnConflict(
                table, getNullColumnHack(table), values, getConflictAlgorithm(table));
        db.setTransactionSuccessful();
      } finally {
        db.endTransaction();
      }
    } finally {
      db.releaseReference();
    }

    if (id == -1) {
      return null;
    }

    // notify change essentially indicates to any users with active cursors
    // that they need to "reload" the data
    notifyChange(uri);
    return ContentUris.withAppendedId(uri, id);
  }
Exemplo n.º 28
0
 public long insertListOfSurveyQuestion(
     DatabaseOperations dop,
     String questionnaireID,
     String creationdate,
     String lastupdate,
     String uniquecode,
     String companyID,
     String agentID,
     String screen_type,
     String status,
     String title,
     String font,
     String message_type,
     String completion_text) {
   try {
     completion_text = completion_text.replace("'", "''");
     title = title.replace("'", "''");
     SQLiteDatabase SQ = dop.getWritableDatabase();
     ContentValues cv = new ContentValues();
     cv.put(TableInfo_ListOf_Survey.QUESTIONNAIRE_ID, questionnaireID);
     cv.put(TableInfo_ListOf_Survey.CREATEION_DATE, creationdate);
     cv.put(TableInfo_ListOf_Survey.LAST_UPDATED, lastupdate);
     cv.put(TableInfo_ListOf_Survey.UNIQUE_CODE, uniquecode);
     cv.put(TableInfo_ListOf_Survey.COMPANY_ID, companyID);
     cv.put(TableInfo_ListOf_Survey.AGENT_ID, agentID);
     cv.put(TableInfo_ListOf_Survey.SCREEN_TYPE, screen_type);
     cv.put(TableInfo_ListOf_Survey.STATUS, status);
     cv.put(TableInfo_ListOf_Survey.TITLE, title);
     cv.put(TableInfo_ListOf_Survey.FONT, font);
     cv.put(TableInfo_ListOf_Survey.MESSAGE_TYPE, message_type);
     cv.put(TableInfo_ListOf_Survey.COMPLETION_TEXT, completion_text);
     long k =
         SQ.insertWithOnConflict(
             TableInfo_ListOf_Survey.TABLE_NAME, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
     Log.d("database operation", "one row inserted");
     return k;
   } catch (Exception ex) {
     return -1;
   }
 }
Exemplo n.º 29
0
  private Long putStatus(SQLiteDatabase db, Status status, String appUserId) {
    if (status == null) {
      return 0L;
    }

    putUser(db, status.user);

    // putting Status datas
    ContentValues values = new ContentValues();
    values.put(StatusTable.COLUMN_TEXT, status.text);
    values.put(StatusTable.COLUMN_ID, status.id);
    values.put(StatusTable.COLUMN_APP_USER_ID, appUserId);
    values.put(StatusTable.COLUMN_USER_ID, status.user.id);
    values.put(StatusTable.COLUMN_TYPE, status.type);
    values.put(StatusTable.COLUMN_ANSWERS_COUNT, status.answers_count);
    values.put(StatusTable.COLUMN_LOGEABLE_TYPE, status.logeable_type);

    if (status.createdAtInMillis == 0) {
      try {
        status.createdAtInMillis = DateUtil.dfIn.parse(status.created_at).getTime();
      } catch (ParseException e) {
        e.printStackTrace();
      }
    }
    values.put(StatusTable.COLUMN_CREATED_AT_IN_MILLIS, status.createdAtInMillis);

    values.put(StatusTable.COLUMN_LECTURE_ALREADY_SEEN, (status.lectureAreadySeen ? 1 : 0));
    values.put(StatusTable.COLUMN_LAST_SEEN, (status.lastSeen ? 1 : 0));
    values.put(StatusTable.COLUMN_IGNORABLE_IN_SYNC, (status.ignorableInSync ? 1 : 0));

    long id =
        db.insertWithOnConflict(StatusTable.NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);

    // putting links datas
    for (Link link : status.links) {
      putLink(db, link, status.id);
    }

    return id;
  }
Exemplo n.º 30
0
  @Override
  public Uri insert(Uri uri, ContentValues values) {
    Uri ret = null;

    if (sURIMatcher.match(uri) != StatusContract.STATUS_DIR) {
      throw new IllegalArgumentException("Illegal uri:" + uri);
    }

    SQLiteDatabase db = dbHelper.getWritableDatabase();
    long rowId =
        db.insertWithOnConflict(StatusContract.TABLE, null, values, SQLiteDatabase.CONFLICT_IGNORE);

    if (rowId != -1) {
      long id = values.getAsLong(StatusContract.Column.ID);
      ret = ContentUris.withAppendedId(uri, id);
      Log.d(TAG, "inserted uri:" + ret);

      getContext().getContentResolver().notifyChange(uri, null);
    }

    return ret;
  }