protected void saveBookSeriesInfo(long bookId, SeriesInfo seriesInfo) {
    if (myGetSeriesIdStatement == null) {
      myGetSeriesIdStatement =
          myDatabase.compileStatement("SELECT series_id FROM Series WHERE name = ?");
      myInsertSeriesStatement =
          myDatabase.compileStatement("INSERT OR IGNORE INTO Series (name) VALUES (?)");
      myInsertBookSeriesStatement =
          myDatabase.compileStatement(
              "INSERT OR REPLACE INTO BookSeries (book_id,series_id,book_index) VALUES (?,?,?)");
      myDeleteBookSeriesStatement =
          myDatabase.compileStatement("DELETE FROM BookSeries WHERE book_id = ?");
    }

    if (seriesInfo == null) {
      myDeleteBookSeriesStatement.bindLong(1, bookId);
      myDeleteBookSeriesStatement.execute();
    } else {
      long seriesId;
      try {
        myGetSeriesIdStatement.bindString(1, seriesInfo.Name);
        seriesId = myGetSeriesIdStatement.simpleQueryForLong();
      } catch (SQLException e) {
        myInsertSeriesStatement.bindString(1, seriesInfo.Name);
        seriesId = myInsertSeriesStatement.executeInsert();
      }
      myInsertBookSeriesStatement.bindLong(1, bookId);
      myInsertBookSeriesStatement.bindLong(2, seriesId);
      SQLiteUtil.bindString(
          myInsertBookSeriesStatement,
          3,
          seriesInfo.Index != null ? seriesInfo.Index.toString() : null);
      myInsertBookSeriesStatement.execute();
    }
  }
  protected void saveBookAuthorInfo(long bookId, long index, Author author) {
    if (myGetAuthorIdStatement == null) {
      myGetAuthorIdStatement =
          myDatabase.compileStatement(
              "SELECT author_id FROM Authors WHERE name = ? AND sort_key = ?");
      myInsertAuthorStatement =
          myDatabase.compileStatement("INSERT OR IGNORE INTO Authors (name,sort_key) VALUES (?,?)");
      myInsertBookAuthorStatement =
          myDatabase.compileStatement(
              "INSERT OR REPLACE INTO BookAuthor (book_id,author_id,author_index) VALUES (?,?,?)");
    }

    long authorId;
    try {
      myGetAuthorIdStatement.bindString(1, author.DisplayName);
      myGetAuthorIdStatement.bindString(2, author.SortKey);
      authorId = myGetAuthorIdStatement.simpleQueryForLong();
    } catch (SQLException e) {
      myInsertAuthorStatement.bindString(1, author.DisplayName);
      myInsertAuthorStatement.bindString(2, author.SortKey);
      authorId = myInsertAuthorStatement.executeInsert();
    }
    myInsertBookAuthorStatement.bindLong(1, bookId);
    myInsertBookAuthorStatement.bindLong(2, authorId);
    myInsertBookAuthorStatement.bindLong(3, index);
    myInsertBookAuthorStatement.execute();
  }
 private long getTagId(Tag tag) {
   if (myGetTagIdStatement == null) {
     myGetTagIdStatement =
         myDatabase.compileStatement("SELECT tag_id FROM Tags WHERE parent_id = ? AND name = ?");
     myCreateTagIdStatement =
         myDatabase.compileStatement("INSERT OR IGNORE INTO Tags (parent_id,name) VALUES (?,?)");
   }
   {
     final Long id = myIdByTag.get(tag);
     if (id != null) {
       return id;
     }
   }
   if (tag.Parent != null) {
     myGetTagIdStatement.bindLong(1, getTagId(tag.Parent));
   } else {
     myGetTagIdStatement.bindNull(1);
   }
   myGetTagIdStatement.bindString(2, tag.Name);
   long id;
   try {
     id = myGetTagIdStatement.simpleQueryForLong();
   } catch (SQLException e) {
     if (tag.Parent != null) {
       myCreateTagIdStatement.bindLong(1, getTagId(tag.Parent));
     } else {
       myCreateTagIdStatement.bindNull(1);
     }
     myCreateTagIdStatement.bindString(2, tag.Name);
     id = myCreateTagIdStatement.executeInsert();
   }
   myIdByTag.put(tag, id);
   myTagById.put(id, tag);
   return id;
 }
  private void insertPhone(
      Cursor c,
      SQLiteStatement phoneInsert,
      SQLiteStatement phoneLookupInsert,
      SQLiteStatement hasPhoneUpdate) {
    long lastUpdatedContact = -1;
    long id = c.getLong(PhonesQuery.PERSON);
    String number = c.getString(PhonesQuery.NUMBER);
    String normalizedNumber = null;
    if (number != null) {
      normalizedNumber = PhoneNumberUtils.getStrippedReversed(number);
    }
    phoneInsert.bindLong(PhoneInsert.RAW_CONTACT_ID, id);
    phoneInsert.bindLong(PhoneInsert.MIMETYPE_ID, mPhoneMimetypeId);
    bindString(phoneInsert, PhoneInsert.IS_PRIMARY, c.getString(PhonesQuery.ISPRIMARY));
    bindString(phoneInsert, PhoneInsert.NUMBER, number);
    bindString(phoneInsert, PhoneInsert.TYPE, c.getString(PhonesQuery.TYPE));
    bindString(phoneInsert, PhoneInsert.LABEL, c.getString(PhonesQuery.LABEL));
    bindString(phoneInsert, PhoneInsert.NORMALIZED_NUMBER, normalizedNumber);

    long dataId = insert(phoneInsert);
    if (normalizedNumber != null) {
      phoneLookupInsert.bindLong(PhoneLookupInsert.RAW_CONTACT_ID, id);
      phoneLookupInsert.bindLong(PhoneLookupInsert.DATA_ID, dataId);
      phoneLookupInsert.bindString(PhoneLookupInsert.NORMALIZED_NUMBER, normalizedNumber);
      insert(phoneLookupInsert);

      if (lastUpdatedContact != id) {
        lastUpdatedContact = id;
        hasPhoneUpdate.bindLong(HasPhoneNumberUpdate.CONTACT_ID, id);
        hasPhoneUpdate.execute();
      }
    }
  }
Example #5
0
 protected void bindValues(SQLiteStatement sqlitestatement, FoodLocale foodlocale) {
   long l1 = 1L;
   sqlitestatement.clearBindings();
   Object obj = foodlocale.getId();
   if (obj != null) {
     sqlitestatement.bindLong(1, ((Long) (obj)).longValue());
   }
   obj = foodlocale.getValue();
   if (obj != null) {
     sqlitestatement.bindString(2, ((String) (obj)));
   }
   obj = foodlocale.getLabel();
   if (obj != null) {
     sqlitestatement.bindString(3, ((String) (obj)));
   }
   obj = foodlocale.getSupportsLookupByBarCode();
   long l;
   if (obj != null) {
     if (((Boolean) (obj)).booleanValue()) {
       l = 1L;
     } else {
       l = 0L;
     }
     sqlitestatement.bindLong(4, l);
   }
   foodlocale = foodlocale.getImageUpload();
   if (foodlocale != null) {
     if (foodlocale.booleanValue()) {
       l = l1;
     } else {
       l = 0L;
     }
     sqlitestatement.bindLong(5, l);
   }
 }
 /** @inheritdoc */
 @Override
 protected void bindValues(SQLiteStatement stmt, ConquestMoveDisplacements entity) {
   stmt.clearBindings();
   stmt.bindLong(1, entity.getId());
   stmt.bindString(2, entity.getIdentifier());
   stmt.bindLong(3, entity.getAffectsTarget() ? 1L : 0L);
 }
  private void insertStructuredName(Cursor c, SQLiteStatement insert) {
    String name = c.getString(PeopleQuery.NAME);
    if (TextUtils.isEmpty(name)) {
      return;
    }

    long id = c.getLong(PeopleQuery._ID);

    insert.bindLong(StructuredNameInsert.RAW_CONTACT_ID, id);
    insert.bindLong(StructuredNameInsert.MIMETYPE_ID, mStructuredNameMimetypeId);
    bindString(insert, StructuredNameInsert.DISPLAY_NAME, name);

    NameSplitter.Name splitName = new NameSplitter.Name();
    mNameSplitter.split(splitName, name);

    bindString(insert, StructuredNameInsert.PREFIX, splitName.getPrefix());
    bindString(insert, StructuredNameInsert.GIVEN_NAME, splitName.getGivenNames());
    bindString(insert, StructuredNameInsert.MIDDLE_NAME, splitName.getMiddleName());
    bindString(insert, StructuredNameInsert.FAMILY_NAME, splitName.getFamilyName());
    bindString(insert, StructuredNameInsert.SUFFIX, splitName.getSuffix());

    if (mPhoneticNameAvailable) {
      // TODO: add the ability to insert an unstructured phonetic name
      String phoneticName = c.getString(PeopleQuery.PHONETIC_NAME);
    }

    long dataId = insert(insert);

    mContactsProvider.insertNameLookupForStructuredName(id, dataId, name);
  }
  @Override
  protected final void bindValues(SQLiteStatement stmt, TestData entity) {
    stmt.clearBindings();

    Long id = entity.getId();
    if (id != null) {
      stmt.bindLong(1, id);
    }

    String testString = entity.getTestString();
    if (testString != null) {
      stmt.bindString(2, testString);
    }

    Long testLong = entity.getTestLong();
    if (testLong != null) {
      stmt.bindLong(3, testLong);
    }

    java.util.Date testDate = entity.getTestDate();
    if (testDate != null) {
      stmt.bindLong(4, testDate.getTime());
    }

    Integer testInt = entity.getTestInt();
    if (testInt != null) {
      stmt.bindLong(5, testInt);
    }

    Boolean testBoolean = entity.getTestBoolean();
    if (testBoolean != null) {
      stmt.bindLong(6, testBoolean ? 1L : 0L);
    }
  }
Example #9
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, DBCover entity) {
    stmt.clearBindings();

    Long id = entity.getId();
    if (id != null) {
      stmt.bindLong(1, id);
    }

    String urlSmall = entity.getUrlSmall();
    if (urlSmall != null) {
      stmt.bindString(2, urlSmall);
    }

    Integer height = entity.getHeight();
    if (height != null) {
      stmt.bindLong(3, height);
    }

    String url = entity.getUrl();
    if (url != null) {
      stmt.bindString(4, url);
    }

    Integer width = entity.getWidth();
    if (width != null) {
      stmt.bindLong(5, width);
    }
  }
Example #10
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, stepbean entity) {
    stmt.clearBindings();

    String day = entity.getDay();
    if (day != null) {
      stmt.bindString(1, day);
    }

    Long bengin = entity.getBengin();
    if (bengin != null) {
      stmt.bindLong(2, bengin);
    }

    Long end = entity.getEnd();
    if (end != null) {
      stmt.bindLong(3, end);
    }

    Integer stepcount = entity.getStepcount();
    if (stepcount != null) {
      stmt.bindLong(4, stepcount);
    }

    Integer source = entity.getSource();
    if (source != null) {
      stmt.bindLong(5, source);
    }
  }
Example #11
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, Person entity) {
    stmt.clearBindings();

    Long id = entity.getId();
    if (id != null) {
      stmt.bindLong(1, id);
    }
    stmt.bindString(2, entity.getName());

    Integer age = entity.getAge();
    if (age != null) {
      stmt.bindLong(3, age);
    }

    Integer height = entity.getHeight();
    if (height != null) {
      stmt.bindLong(4, height);
    }

    String introduction = entity.getIntroduction();
    if (introduction != null) {
      stmt.bindString(5, introduction);
    }
  }
Example #12
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, Feeling entity) {
    stmt.clearBindings();

    Long id = entity.getId();
    if (id != null) {
      stmt.bindLong(1, id);
    }

    String content = entity.getContent();
    if (content != null) {
      stmt.bindString(2, content);
    }

    Long serverId = entity.getServerId();
    if (serverId != null) {
      stmt.bindLong(3, serverId);
    }

    Integer statusFlag = entity.getStatusFlag();
    if (statusFlag != null) {
      stmt.bindLong(4, statusFlag);
    }
    stmt.bindLong(5, entity.getLocationId());
  }
 /** @inheritdoc */
 @Override
 protected void bindValues(SQLiteStatement stmt, ConquestWarriorNames entity) {
   stmt.clearBindings();
   stmt.bindLong(1, entity.getWarriorId());
   stmt.bindLong(2, entity.getLocalLanguageId());
   stmt.bindString(3, entity.getName());
 }
  @Override
  public void addGBActivitySamples(ActivitySample[] activitySamples) {
    try (SQLiteDatabase db = this.getWritableDatabase()) {

      String sql =
          "INSERT INTO "
              + TABLE_GBACTIVITYSAMPLES
              + " ("
              + KEY_TIMESTAMP
              + ","
              + KEY_PROVIDER
              + ","
              + KEY_INTENSITY
              + ","
              + KEY_STEPS
              + ","
              + KEY_TYPE
              + ")"
              + " VALUES (?,?,?,?,?);";
      SQLiteStatement statement = db.compileStatement(sql);
      db.beginTransaction();

      for (ActivitySample activitySample : activitySamples) {
        statement.clearBindings();
        statement.bindLong(1, activitySample.getTimestamp());
        statement.bindLong(2, activitySample.getProvider().getID());
        statement.bindLong(3, activitySample.getRawIntensity());
        statement.bindLong(4, activitySample.getSteps());
        statement.bindLong(5, activitySample.getRawKind());
        statement.execute();
      }
      db.setTransactionSuccessful();
      db.endTransaction();
    }
  }
Example #15
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, Comment entity) {
    stmt.clearBindings();

    Long id = entity.getId();
    if (id != null) {
      stmt.bindLong(1, id);
    }

    String content = entity.getContent();
    if (content != null) {
      stmt.bindString(2, content);
    }

    String userId = entity.getUserId();
    if (userId != null) {
      stmt.bindString(3, userId);
    }

    String postId = entity.getPostId();
    if (postId != null) {
      stmt.bindString(4, postId);
    }

    Long idCatPost = entity.getIdCatPost();
    if (idCatPost != null) {
      stmt.bindLong(5, idCatPost);
    }
  }
Example #16
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, TokensBD entity) {
    stmt.clearBindings();

    Long id = entity.getId();
    if (id != null) {
      stmt.bindLong(1, id);
    }

    Long expiresIn = entity.getExpiresIn();
    if (expiresIn != null) {
      stmt.bindLong(2, expiresIn);
    }

    Long expiresAt = entity.getExpiresAt();
    if (expiresAt != null) {
      stmt.bindLong(3, expiresAt);
    }

    String tokenType = entity.getTokenType();
    if (tokenType != null) {
      stmt.bindString(4, tokenType);
    }

    String refreshToken = entity.getRefreshToken();
    if (refreshToken != null) {
      stmt.bindString(5, refreshToken);
    }

    String accessToken = entity.getAccessToken();
    if (accessToken != null) {
      stmt.bindString(6, accessToken);
    }
  }
  @MediumTest
  public void testSimpleQuery() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (num INTEGER NOT NULL, str TEXT NOT NULL);");
    mDatabase.execSQL("INSERT INTO test VALUES (1234, 'hello');");
    SQLiteStatement statement1 = mDatabase.compileStatement("SELECT num FROM test WHERE str = ?");
    SQLiteStatement statement2 = mDatabase.compileStatement("SELECT str FROM test WHERE num = ?");

    try {
      statement1.bindString(1, "hello");
      long value = statement1.simpleQueryForLong();
      assertEquals(1234, value);

      statement1.bindString(1, "world");
      statement1.simpleQueryForLong();
      fail("shouldn't get here");
    } catch (SQLiteDoneException e) {
      // expected
    }

    try {
      statement2.bindLong(1, 1234);
      String value = statement1.simpleQueryForString();
      assertEquals("hello", value);

      statement2.bindLong(1, 5678);
      statement1.simpleQueryForString();
      fail("shouldn't get here");
    } catch (SQLiteDoneException e) {
      // expected
    }

    statement1.close();
    statement2.close();
  }
Example #18
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, MunkaKep entity) {
    stmt.clearBindings();

    Long munkaKepID = entity.getMunkaKepID();
    if (munkaKepID != null) {
      stmt.bindLong(1, munkaKepID);
    }

    String munkaKepPath = entity.getMunkaKepPath();
    if (munkaKepPath != null) {
      stmt.bindString(2, munkaKepPath);
    }

    String munkaKepDate = entity.getMunkaKepDate();
    if (munkaKepDate != null) {
      stmt.bindString(3, munkaKepDate);
    }

    Boolean munkaKepIsUploaded = entity.getMunkaKepIsUploaded();
    if (munkaKepIsUploaded != null) {
      stmt.bindLong(4, munkaKepIsUploaded ? 1l : 0l);
    }

    Boolean munkaKepIsActive = entity.getMunkaKepIsActive();
    if (munkaKepIsActive != null) {
      stmt.bindLong(5, munkaKepIsActive ? 1l : 0l);
    }

    Long munkaID = entity.getMunkaID();
    if (munkaID != null) {
      stmt.bindLong(6, munkaID);
    }
  }
 /** @inheritdoc */
 @Override
 protected void bindValues(SQLiteStatement stmt, ConquestWarriorSpecialties entity) {
   stmt.clearBindings();
   stmt.bindLong(1, entity.getWarriorId());
   stmt.bindLong(2, entity.getTypeId());
   stmt.bindLong(3, entity.getSlot());
 }
Example #20
0
  public void updateHomeWork(HomeWork hw) {
    try {
      mDb.beginTransaction();
      if (hw != null) {

        mUpdateHomeWorkStatement.clearBindings();
        if (hw.isComplite()) {
          mUpdateHomeWorkStatement.bindLong(1, 1);
          NotificationManager.getInstance().removeNotification(hw);

        } else {
          mUpdateHomeWorkStatement.bindLong(1, 0);
          NotificationManager.getInstance().addNewNotification(hw);
        }

        if (hw.getMessage() != null) {
          mUpdateHomeWorkStatement.bindString(2, hw.getMessage());
        }

        if (hw.getMessage() != null) {
          mUpdateHomeWorkStatement.bindBlob(3, Slipper.serializeObject(hw.getImages()));
        }

        mUpdateHomeWorkStatement.bindLong(4, hw.getId());
        mUpdateHomeWorkStatement.execute();
      }
      mDb.setTransactionSuccessful();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      mDb.endTransaction();
    }
  }
Example #21
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, ThirdGameDownInfo entity) {
    stmt.clearBindings();

    Long id = entity.getId();
    if (id != null) {
      stmt.bindLong(1, id);
    }

    String gameURLId = entity.getGameURLId();
    if (gameURLId != null) {
      stmt.bindString(2, gameURLId);
    }

    String url = entity.getUrl();
    if (url != null) {
      stmt.bindString(3, url);
    }

    Integer downToken = entity.getDownToken();
    if (downToken != null) {
      stmt.bindLong(4, downToken);
    }

    String remark = entity.getRemark();
    if (remark != null) {
      stmt.bindString(5, remark);
    }

    String logoUrl = entity.getLogoUrl();
    if (logoUrl != null) {
      stmt.bindString(6, logoUrl);
    }
    stmt.bindString(7, entity.getGameId());
  }
Example #22
0
  public void saveTile(Tile tile, ByteArrayOutputStream data, boolean success) {
    byte[] bytes = null;

    if (success) bytes = data.toByteArray();

    synchronized (mCacheBuffers) {
      data.reset();
      mCacheBuffers.add(data);
    }

    if (dbg) log.debug("store tile {} {}", tile, Boolean.valueOf(success));

    if (!success) return;

    synchronized (mStmtPutTile) {
      mStmtPutTile.bindLong(1, tile.tileX);
      mStmtPutTile.bindLong(2, tile.tileY);
      mStmtPutTile.bindLong(3, tile.zoomLevel);
      mStmtPutTile.bindLong(4, 0);
      mStmtPutTile.bindLong(5, 0);
      mStmtPutTile.bindBlob(6, bytes);

      mStmtPutTile.execute();
      mStmtPutTile.clearBindings();
    }
  }
Example #23
0
  /** update the level and count for the given flashcard in the database. */
  private void updateFlashcard(Flashcard fc) {
    openDB();

    _curDB.beginTransaction();
    try {
      // Delete old entry if any.
      SQLiteStatement dStmt = getCompiledStatement(SQL_DELETE_FCS);
      dStmt.bindString(1, fc.getLang1Str());
      dStmt.execute();

      // insert new state entry.
      SQLiteStatement iStmt = getCompiledStatement(SQL_INSERT_FCS);
      iStmt.bindString(1, fc.getLang1Str());
      iStmt.bindLong(2, fc.getLevel());
      iStmt.bindLong(3, fc.getRightGuessCount());
      iStmt.execute();
      _curDB.setTransactionSuccessful();
    } catch (SQLException e) {
      MsgDispatcher.sendMessageToUI(
          MsgType.MSG_SHOW_ERROR_MSG, 0, 0, "unable to update id=" + fc.getID());
    } finally {
      _curDB.endTransaction();
    }

    // this flashcard is no longer used by anyone so release it.
    fc.release();
  }
Example #24
0
 public void insertFiles(File[] files) {
   SQLiteDatabase database = dbHelper.getWritableDatabase();
   SQLiteStatement statement =
       database.compileStatement(
           "INSERT INTO "
               + TABLE_NAME
               + " ("
               + COL_FILENAME
               + ", "
               + COL_FILESIZE
               + ", "
               + COL_TIMESTAMP
               + ") VALUES (?, ?, ?)");
   database.beginTransaction();
   try {
     for (File file : files) {
       statement.bindString(1, file.getName());
       statement.bindLong(2, file.length());
       statement.bindLong(3, file.lastModified());
       statement.executeInsert();
     }
     database.setTransactionSuccessful();
   } finally {
     database.endTransaction();
   }
 }
Example #25
0
  public void hapusBukmakByAri(int ari, int jenis) {
    SQLiteDatabase db = helper.getWritableDatabase();
    db.beginTransaction();
    try {
      long _id;

      SQLiteStatement stmt =
          db.compileStatement(
              "select _id from "
                  + Db.TABEL_Bukmak2
                  + " where "
                  + Db.Bukmak2.jenis
                  + "=? and "
                  + Db.Bukmak2.ari
                  + "=?"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
      try {
        stmt.bindLong(1, jenis);
        stmt.bindLong(2, ari);
        _id = stmt.simpleQueryForLong();
      } finally {
        stmt.close();
      }

      String[] params = {String.valueOf(_id)};
      db.delete(Db.TABEL_Bukmak2_Label, Db.Bukmak2_Label.bukmak2_id + "=?", params); // $NON-NLS-1$
      db.delete(Db.TABEL_Bukmak2, "_id=?", params); // $NON-NLS-1$
      db.setTransactionSuccessful();
    } finally {
      db.endTransaction();
    }
  }
  @Override
  public void changeStoredSamplesType(
      int timestampFrom, int timestampTo, byte kind, SampleProvider provider) {
    try (SQLiteDatabase db = this.getReadableDatabase()) {
      String sql =
          "UPDATE "
              + TABLE_GBACTIVITYSAMPLES
              + " SET "
              + KEY_TYPE
              + "= ? WHERE "
              + KEY_PROVIDER
              + " = ? AND "
              + KEY_TIMESTAMP
              + " >= ? AND "
              + KEY_TIMESTAMP
              + " < ? ;"; // do not use BETWEEN because the range is inclusive in that case!

      SQLiteStatement statement = db.compileStatement(sql);
      statement.bindLong(1, kind);
      statement.bindLong(2, provider.getID());
      statement.bindLong(3, timestampFrom);
      statement.bindLong(4, timestampTo);
      statement.execute();
    }
  }
  private void insertStructuredName(Cursor c, SQLiteStatement insert) {
    String name = c.getString(PeopleQuery.NAME);
    if (TextUtils.isEmpty(name)) {
      return;
    }

    long id = c.getLong(PeopleQuery._ID);

    insert.bindLong(StructuredNameInsert.RAW_CONTACT_ID, id);
    insert.bindLong(StructuredNameInsert.MIMETYPE_ID, mStructuredNameMimetypeId);
    bindString(insert, StructuredNameInsert.DISPLAY_NAME, name);

    NameSplitter.Name splitName = new NameSplitter.Name();
    mNameSplitter.split(splitName, name);

    bindString(insert, StructuredNameInsert.PREFIX, splitName.getPrefix());
    bindString(insert, StructuredNameInsert.GIVEN_NAME, splitName.getGivenNames());
    bindString(insert, StructuredNameInsert.MIDDLE_NAME, splitName.getMiddleName());
    bindString(insert, StructuredNameInsert.FAMILY_NAME, splitName.getFamilyName());
    bindString(insert, StructuredNameInsert.SUFFIX, splitName.getSuffix());
    final String joined = mNameSplitter.join(splitName, true);
    bindString(insert, StructuredNameInsert.DISPLAY_NAME, joined);

    if (mPhoneticNameAvailable) {
      String phoneticName = c.getString(PeopleQuery.PHONETIC_NAME);
      if (phoneticName != null) {
        int index = phoneticName.indexOf(' ');
        if (index == -1) {
          splitName.phoneticFamilyName = phoneticName;
        } else {
          splitName.phoneticFamilyName = phoneticName.substring(0, index).trim();
          splitName.phoneticGivenName = phoneticName.substring(index + 1).trim();
        }
      }
    }

    mNameSplitter.guessNameStyle(splitName);

    int fullNameStyle = splitName.getFullNameStyle();
    insert.bindLong(StructuredNameInsert.FULL_NAME_STYLE, fullNameStyle);
    bindString(insert, StructuredNameInsert.PHONETIC_FAMILY_NAME, splitName.phoneticFamilyName);
    bindString(insert, StructuredNameInsert.PHONETIC_MIDDLE_NAME, splitName.phoneticMiddleName);
    bindString(insert, StructuredNameInsert.PHONETIC_GIVEN_NAME, splitName.phoneticGivenName);
    insert.bindLong(StructuredNameInsert.PHONETIC_NAME_STYLE, splitName.phoneticNameStyle);

    long dataId = insert(insert);

    mContactsProvider.insertNameLookupForStructuredName(
        id, dataId, name, mNameSplitter.getAdjustedFullNameStyle(fullNameStyle));
    if (splitName.phoneticFamilyName != null
        || splitName.phoneticMiddleName != null
        || splitName.phoneticGivenName != null) {
      mContactsProvider.insertNameLookupForPhoneticName(
          id,
          dataId,
          splitName.phoneticFamilyName,
          splitName.phoneticMiddleName,
          splitName.phoneticGivenName);
    }
  }
Example #28
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, p2p9 entity) {
    stmt.clearBindings();

    Long id = entity.getId();
    if (id != null) {
      stmt.bindLong(1, id);
    }

    Integer flipc = entity.getFlipc();
    if (flipc != null) {
      stmt.bindLong(2, flipc);
    }

    Integer cpmr = entity.getCpmr();
    if (cpmr != null) {
      stmt.bindLong(3, cpmr);
    }

    Integer encd = entity.getEncd();
    if (encd != null) {
      stmt.bindLong(4, encd);
    }

    Integer adp = entity.getAdp();
    if (adp != null) {
      stmt.bindLong(5, adp);
    }

    Integer sbv = entity.getSbv();
    if (sbv != null) {
      stmt.bindLong(6, sbv);
    }

    Integer adc = entity.getAdc();
    if (adc != null) {
      stmt.bindLong(7, adc);
    }

    Integer pex = entity.getPex();
    if (pex != null) {
      stmt.bindLong(8, pex);
    }

    Integer origen = entity.getOrigen();
    if (origen != null) {
      stmt.bindLong(9, origen);
    }

    String obser = entity.getObser();
    if (obser != null) {
      stmt.bindString(10, obser);
    }

    Integer id_formulario = entity.getId_formulario();
    if (id_formulario != null) {
      stmt.bindLong(11, id_formulario);
    }
  }
 private void insertNormalizedNameLookup(
     SQLiteStatement stmt, long rawContactId, long dataId, int lookupType, String normalizedName) {
   stmt.bindLong(1, rawContactId);
   stmt.bindLong(2, dataId);
   stmt.bindLong(3, lookupType);
   stmt.bindString(4, normalizedName);
   stmt.executeInsert();
 }
 /**
  * This method is called when a job is pulled to run. It is properly marked so that it won't be
  * returned from next job queries.
  *
  * <p>Same mechanism is also used for cancelled jobs.
  *
  * @param jobHolder The job holder to update session id
  */
 private void setSessionIdOnJob(JobHolder jobHolder) {
   SQLiteStatement stmt = sqlHelper.getOnJobFetchedForRunningStatement();
   jobHolder.setRunCount(jobHolder.getRunCount() + 1);
   jobHolder.setRunningSessionId(sessionId);
   stmt.clearBindings();
   stmt.bindLong(1, jobHolder.getRunCount());
   stmt.bindLong(2, sessionId);
   stmt.bindString(3, jobHolder.getId());
   stmt.execute();
 }