public long insertPlayerRankingItem(ATPRanking rankingItem) { ContentValues cv = new ContentValues(); cv.put(AppDatabase.PlayerRankingDatabase.PLAYER_ID, rankingItem.getPlayerId()); cv.put(AppDatabase.PlayerRankingDatabase.FIRST_NAME, rankingItem.getPlayerFirstName()); cv.put(AppDatabase.PlayerRankingDatabase.LAST_NAME, rankingItem.getPlayerLastName()); cv.put(AppDatabase.PlayerRankingDatabase.SITE_URL, rankingItem.getPlayerWebSite()); cv.put(AppDatabase.PlayerRankingDatabase.PROFILE_URL, rankingItem.getPlayerProfileUrl()); cv.put(AppDatabase.PlayerRankingDatabase.PHOTO_URL, rankingItem.getPlayerPhotoUrl()); cv.put(AppDatabase.PlayerRankingDatabase.POINTS, rankingItem.getPlayerTotalPoints()); cv.put(AppDatabase.PlayerRankingDatabase.TOURNAMENTS_YTD, rankingItem.getPlayerTournas()); cv.put( AppDatabase.PlayerRankingDatabase.PRIZE_MONEY_YTD, rankingItem.getPlayerPrizeMoneyCurrent()); cv.put( AppDatabase.PlayerRankingDatabase.PRIZE_MONEY_TOTAL, rankingItem.getPlayerPrizeMoneyTotal()); cv.put(AppDatabase.PlayerRankingDatabase.AGE, rankingItem.getPlayerAge()); cv.put(AppDatabase.PlayerRankingDatabase.BIRTHPLACE, rankingItem.getPlayerBirthplace()); cv.put(AppDatabase.PlayerRankingDatabase.RANK_YTD, rankingItem.getPlayerRank()); cv.put(AppDatabase.PlayerRankingDatabase.RANK_HIGHEST, rankingItem.getPlayerRankHigh()); cv.put(AppDatabase.PlayerRankingDatabase.TITLES_YTD, rankingItem.getPlayerTitlesYTD()); cv.put(AppDatabase.PlayerRankingDatabase.TITLES_TOTAL, rankingItem.getPlayerTitlesCareer()); cv.put( AppDatabase.PlayerRankingDatabase.TITLES_SLAMS_YTD, rankingItem.getPlayerSlamTitlesYTD()); cv.put( AppDatabase.PlayerRankingDatabase.TITLES_SLAMS_TOTAL, rankingItem.getPlayerSlamTitlesCareer()); cv.put( AppDatabase.PlayerRankingDatabase.TITLES_MASTERS1000_YTD, rankingItem.getPlayerMasters1000TitlesYTD()); cv.put( AppDatabase.PlayerRankingDatabase.TITLES_MASTERS1000_TOTAL, rankingItem.getPlayerMasters1000TitlesCareer()); cv.put(AppDatabase.PlayerRankingDatabase.SHARE_TEXT, rankingItem.getShareText()); cv.put(AppDatabase.PlayerRankingDatabase.IS_STARRED, rankingItem.getIsStarred()); cv.put(AppDatabase.PlayerRankingDatabase.IS_SHARED, rankingItem.getIsShared()); return getWritableDatabase() .insertWithOnConflict( AppDatabase.PlayerRankingDatabase.TABLE_NAME, null, cv, SQLiteDatabase.CONFLICT_IGNORE); }
public boolean updatePlayerRankingItem(ATPRanking rankingItem) { ContentValues cv = new ContentValues(); cv.put(AppDatabase.PlayerRankingDatabase.FIRST_NAME, rankingItem.getPlayerFirstName()); cv.put(AppDatabase.PlayerRankingDatabase.LAST_NAME, rankingItem.getPlayerLastName()); cv.put(AppDatabase.PlayerRankingDatabase.AGE, rankingItem.getPlayerAge()); cv.put(AppDatabase.PlayerRankingDatabase.RANK_YTD, rankingItem.getPlayerRank()); cv.put(AppDatabase.PlayerRankingDatabase.POINTS, rankingItem.getPlayerTotalPoints()); cv.put(AppDatabase.PlayerRankingDatabase.TITLES_YTD, rankingItem.getPlayerTitlesYTD()); cv.put(AppDatabase.PlayerRankingDatabase.TITLES_TOTAL, rankingItem.getPlayerTitlesCareer()); cv.put( AppDatabase.PlayerRankingDatabase.TITLES_SLAMS_YTD, rankingItem.getPlayerSlamTitlesYTD()); cv.put( AppDatabase.PlayerRankingDatabase.TITLES_SLAMS_TOTAL, rankingItem.getPlayerSlamTitlesCareer()); cv.put( AppDatabase.PlayerRankingDatabase.TITLES_MASTERS1000_YTD, rankingItem.getPlayerMasters1000TitlesYTD()); cv.put( AppDatabase.PlayerRankingDatabase.TITLES_MASTERS1000_TOTAL, rankingItem.getPlayerMasters1000TitlesCareer()); cv.put(AppDatabase.PlayerRankingDatabase.TOURNAMENTS_YTD, rankingItem.getPlayerTournas()); cv.put( AppDatabase.PlayerRankingDatabase.PRIZE_MONEY_YTD, rankingItem.getPlayerPrizeMoneyCurrent()); cv.put( AppDatabase.PlayerRankingDatabase.PRIZE_MONEY_TOTAL, rankingItem.getPlayerPrizeMoneyTotal()); cv.put(AppDatabase.PlayerRankingDatabase.PROFILE_URL, rankingItem.getPlayerProfileUrl()); cv.put(AppDatabase.PlayerRankingDatabase.PHOTO_URL, rankingItem.getPlayerPhotoUrl()); int rowsUpdated = getWritableDatabase() .update( AppDatabase.PlayerRankingDatabase.TABLE_NAME, cv, AppDatabase.PlayerRankingDatabase.PLAYER_ID + "=" + rankingItem.getPlayerId(), null); return rowsUpdated > 0 ? true : false; }