nus-yam/ex-repair huggingface dataset:
Program: 114590
Project: 114590
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  if (isPushForbidden) {
    return;
  }
  ComponentName comp=new ComponentName(context.getPackageName(),GCMIntentService.class.getName());
  startWakefulService(context,(intent.setComponent(comp)));
  setResultCode(Activity.RESULT_OK);
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  isPushForbidden=App.getInstance().getPrefsHelper().getPref(PrefsHelper.PREF_PUSH_NOTIFICATIONS,false);
  if (isPushForbidden) {
    Log.i("String_Node_Str","String_Node_Str");
    return;
  }
  Log.i("String_Node_Str","String_Node_Str");
  ComponentName comp=new ComponentName(context.getPackageName(),GCMIntentService.class.getName());
  startWakefulService(context,(intent.setComponent(comp)));
  setResultCode(Activity.RESULT_OK);
}
Program: 114591
Project: 114591
Buggy source:
private void savePushNotification(boolean value){
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_PUSH_NOTIFICATIONS,value);
}

Fixed version (ground truth):
private void savePushNotification(boolean value){
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_PUSH_NOTIFICATIONS,!value);
}
Program: 114592
Project: 114592
Buggy source:
private void updateUserData(){
  if (isUserDataChanged(fullnameCurrent,emailCurrent,statusCurrent)) {
    trySaveUserData();
  }
}

Fixed version (ground truth):
private void updateUserData(){
  if (isUserDataChanged(fullnameCurrent,emailCurrent,statusCurrent)) {
    saveChanges(fullnameCurrent,emailCurrent);
  }
}
Program: 114593
Project: 114593
Buggy source:
private void saveChanges(final String fullname,final String email) throws IOException {
  if (!isUserDataCorrect()) {
    DialogUtils.showLong(this,getString(R.string.dlg_not_all_fields_entered));
    return;
  }
  showProgress();
  user.setFullName(fullname);
  user.setEmail(email);
  if (isNeedUpdateAvatar) {
    new ReceiveImageFileTask(this).execute(imageHelper,avatarBitmapCurrent,true);
  }
 else {
    String status=statusMessageEditText.getText().toString();
    QBUpdateUserCommand.start(this,user,null,status);
  }
}

Fixed version (ground truth):
private void saveChanges(final String fullname,final String email){
  if (!isUserDataCorrect()) {
    DialogUtils.showLong(this,getString(R.string.dlg_not_all_fields_entered));
    return;
  }
  showProgress();
  user.setFullName(fullname);
  user.setEmail(email);
  if (isNeedUpdateAvatar) {
    new ReceiveImageFileTask(this).execute(imageHelper,avatarBitmapCurrent,true);
  }
 else {
    String status=statusMessageEditText.getText().toString();
    QBUpdateUserCommand.start(this,user,null,status);
  }
}
Program: 114594
Project: 114594
Buggy source:
public BaseCursorAdapter(Context context,Cursor cursor,boolean autoRequery){
  super(context,cursor,autoRequery);
  this.context=context;
  layoutInflater=LayoutInflater.from(context);
  currentUser=App.getInstance().getUser();
  currentLoginType=App.getInstance().getUserLoginType();
  imageHelper=new ImageHelper((android.app.Activity)context);
}

Fixed version (ground truth):
public BaseCursorAdapter(Context context,Cursor cursor,boolean autoRequery){
  super(context,cursor,autoRequery);
  this.context=context;
  resources=context.getResources();
  layoutInflater=LayoutInflater.from(context);
  currentUser=App.getInstance().getUser();
  currentLoginType=App.getInstance().getUserLoginType();
  imageHelper=new ImageHelper((android.app.Activity)context);
}
Program: 114595
Project: 114595
Buggy source:
public DialogsSelectableFriendsAdapter(Context context,Cursor cursor){
  super(context,cursor,true);
  this.context=context;
  selectedFriends=new ArrayList<Friend>();
  layoutInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

Fixed version (ground truth):
public DialogsSelectableFriendsAdapter(Context context,Cursor cursor){
  super(context,cursor,true);
  selectedFriends=new ArrayList<Friend>();
  layoutInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
Program: 114596
Project: 114596
Buggy source:
@Override public void bindView(View view,Context context,Cursor cursor){
  ViewHolder holder=(ViewHolder)view.getTag();
  Friend friend=DatabaseManager.getFriendFromCursor(cursor);
  holder.nameTextView.setText(friend.getFullname());
  holder.statusMessageTextView.setText(friend.getStatus());
  holder.nameTextView.setText(friend.getFullname());
  holder.selectFriendCheckBox.setChecked(friend.isSelected());
  holder.selectFriendCheckBox.setTag(friend);
  if (friend.isOnline()) {
    holder.onlineImageView.setVisibility(View.VISIBLE);
  }
 else {
    holder.onlineImageView.setVisibility(View.INVISIBLE);
  }
  holder.selectFriendCheckBox.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      CheckBox cb=(CheckBox)v;
      Friend friend=(Friend)cb.getTag();
      friend.setSelected(cb.isChecked());
      notifyCounterChanged(cb.isChecked());
      if (cb.isChecked()) {
        selectedFriends.add(friend);
      }
 else       if (selectedFriends.contains(friend)) {
        selectedFriends.remove(friend);
      }
    }
  }
);
  String avatarUrl=getAvatarUrlForFriend(friend);
  displayAvatarImage(avatarUrl,holder.avatarImageView);
  if (!TextUtils.isEmpty(searchCharacters)) {
    TextViewHelper.changeTextColorView(context,holder.nameTextView,searchCharacters);
  }
}

Fixed version (ground truth):
@Override public void bindView(View view,Context context,Cursor cursor){
  final ViewHolder viewHolder=(ViewHolder)view.getTag();
  Friend friend=DatabaseManager.getFriendFromCursor(cursor);
  viewHolder.nameTextView.setText(friend.getFullname());
  viewHolder.statusMessageTextView.setText(friend.getStatus());
  viewHolder.nameTextView.setText(friend.getFullname());
  viewHolder.selectFriendCheckBox.setChecked(friend.isSelected());
  viewHolder.selectFriendCheckBox.setTag(friend);
  if (friend.isOnline()) {
    viewHolder.onlineImageView.setVisibility(View.VISIBLE);
  }
 else {
    viewHolder.onlineImageView.setVisibility(View.INVISIBLE);
  }
  viewHolder.selectFriendCheckBox.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View view){
      CheckBox checkBox=(CheckBox)view;
      Friend friend=(Friend)checkBox.getTag();
      friend.setSelected(checkBox.isChecked());
      notifyCounterChanged(checkBox.isChecked());
      if (checkBox.isChecked()) {
        selectedFriends.add(friend);
      }
 else       if (selectedFriends.contains(friend)) {
        selectedFriends.remove(friend);
      }
      viewHolder.contentRelativeLayout.setBackgroundColor(getBackgroundColorItem(viewHolder.selectFriendCheckBox.isChecked()));
    }
  }
);
  String avatarUrl=getAvatarUrlForFriend(friend);
  displayAvatarImage(avatarUrl,viewHolder.avatarImageView);
  viewHolder.contentRelativeLayout.setBackgroundColor(getBackgroundColorItem(viewHolder.selectFriendCheckBox.isChecked()));
}
Program: 114597
Project: 114597
Buggy source:
public void onClick(View v){
  CheckBox cb=(CheckBox)v;
  Friend friend=(Friend)cb.getTag();
  friend.setSelected(cb.isChecked());
  notifyCounterChanged(cb.isChecked());
  if (cb.isChecked()) {
    selectedFriends.add(friend);
  }
 else   if (selectedFriends.contains(friend)) {
    selectedFriends.remove(friend);
  }
}

Fixed version (ground truth):
public void onClick(View view){
  CheckBox checkBox=(CheckBox)view;
  Friend friend=(Friend)checkBox.getTag();
  friend.setSelected(checkBox.isChecked());
  notifyCounterChanged(checkBox.isChecked());
  if (checkBox.isChecked()) {
    selectedFriends.add(friend);
  }
 else   if (selectedFriends.contains(friend)) {
    selectedFriends.remove(friend);
  }
  viewHolder.contentRelativeLayout.setBackgroundColor(getBackgroundColorItem(viewHolder.selectFriendCheckBox.isChecked()));
}
Program: 114598
Project: 114598
Buggy source:
@Override public View newView(Context context,Cursor cursor,ViewGroup parent){
  ViewHolder holder;
  View view=layoutInflater.inflate(R.layout.list_item_chat_friend_selectable,null);
  holder=new ViewHolder();
  holder.avatarImageView=(RoundedImageView)view.findViewById(R.id.avatar_imageview);
  holder.avatarImageView.setOval(true);
  holder.nameTextView=(TextView)view.findViewById(R.id.name_textview);
  holder.onlineImageView=(ImageView)view.findViewById(R.id.online_imageview);
  holder.statusMessageTextView=(TextView)view.findViewById(R.id.statusMessageTextView);
  holder.selectFriendCheckBox=(CheckBox)view.findViewById(R.id.time_textview);
  view.setTag(holder);
  return view;
}

Fixed version (ground truth):
@Override public View newView(Context context,Cursor cursor,ViewGroup parent){
  ViewHolder viewHolder;
  View view=layoutInflater.inflate(R.layout.list_item_chat_friend_selectable,null);
  viewHolder=new ViewHolder();
  viewHolder.contentRelativeLayout=(RelativeLayout)view.findViewById(R.id.contentRelativeLayout);
  viewHolder.avatarImageView=(RoundedImageView)view.findViewById(R.id.avatar_imageview);
  viewHolder.avatarImageView.setOval(true);
  viewHolder.nameTextView=(TextView)view.findViewById(R.id.name_textview);
  viewHolder.onlineImageView=(ImageView)view.findViewById(R.id.online_imageview);
  viewHolder.statusMessageTextView=(TextView)view.findViewById(R.id.statusMessageTextView);
  viewHolder.selectFriendCheckBox=(CheckBox)view.findViewById(R.id.selected_friend_checkbox);
  view.setTag(viewHolder);
  return view;
}
Program: 114599
Project: 114599
Buggy source:
public void hideProgress(){
  if (progress != null) {
    progress.dismissAllowingStateLoss();
  }
}

Fixed version (ground truth):
public void hideProgress(){
  try {
    if (progress != null && !progress.isDetached()) {
      progress.dismissAllowingStateLoss();
    }
  }
 catch (  NullPointerException npe) {
    ErrorUtils.logError(npe);
  }
}
Program: 114600
Project: 114600
Buggy source:
protected void startLoadDialogMessages(QBDialog dialog,String roomJidId,long lastDateLoad){
  QBLoadDialogMessagesCommand.start(this,dialog,roomJidId,lastDateLoad);
}

Fixed version (ground truth):
protected void startLoadDialogMessages(QBDialog dialog,String roomJidId,long lastDateLoad){
  if (dialog != null) {
    QBLoadDialogMessagesCommand.start(this,dialog,roomJidId,lastDateLoad);
  }
}
Program: 114601
Project: 114601
Buggy source:
@Override public void execute(Bundle bundle){
  dialog=(QBDialog)bundle.getSerializable(QBServiceConsts.EXTRA_DIALOG);
  groupName=dialog.getName();
  roomJidId=dialog.getRoomJid();
  initListView();
}

Fixed version (ground truth):
@Override public void execute(Bundle bundle){
  hideProgress();
  dialog=(QBDialog)bundle.getSerializable(QBServiceConsts.EXTRA_DIALOG);
  groupName=dialog.getName();
  roomJidId=dialog.getRoomJid();
  initListView();
}
Program: 114602
Project: 114602
Buggy source:
private void initChat(){
  Bundle extras=getIntent().getExtras();
  if (getIntent().hasExtra(QBServiceConsts.EXTRA_DIALOG)) {
    dialog=(QBDialog)extras.getSerializable(QBServiceConsts.EXTRA_DIALOG);
    groupName=dialog.getName();
    roomJidId=dialog.getRoomJid();
    QBJoinGroupChatCommand.start(this,roomJidId);
  }
 else {
    friendList=(ArrayList<Friend>)extras.getSerializable(QBServiceConsts.EXTRA_FRIENDS);
    groupName=createChatName();
    QBCreateGroupDialogCommand.start(this,groupName,friendList);
  }
}

Fixed version (ground truth):
private void initChat(){
  Bundle extras=getIntent().getExtras();
  if (getIntent().hasExtra(QBServiceConsts.EXTRA_DIALOG)) {
    dialog=(QBDialog)extras.getSerializable(QBServiceConsts.EXTRA_DIALOG);
    groupName=dialog.getName();
    roomJidId=dialog.getRoomJid();
    QBJoinGroupChatCommand.start(this,roomJidId);
  }
 else {
    showProgress();
    friendList=(ArrayList<Friend>)extras.getSerializable(QBServiceConsts.EXTRA_FRIENDS);
    groupName=createChatName();
    QBCreateGroupDialogCommand.start(this,groupName,friendList);
  }
}
Program: 114603
Project: 114603
Buggy source:
@Override public void execute(Bundle bundle){
  QBUser user=(QBUser)bundle.getSerializable(QBServiceConsts.EXTRA_USER);
  App.getInstance().setUser(user);
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_IMPORT_INITIALIZED,true);
  MainActivity.start(LandingActivity.this);
  finish();
}

Fixed version (ground truth):
@Override public void execute(Bundle bundle){
  QBUser user=(QBUser)bundle.getSerializable(QBServiceConsts.EXTRA_USER);
  App.getInstance().setUser(user);
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_IMPORT_INITIALIZED,true);
  DatabaseManager.clearAllCache(LandingActivity.this);
  MainActivity.start(LandingActivity.this);
  finish();
}
Program: 114604
Project: 114604
Buggy source:
@Override public void execute(Bundle bundle){
  clearCache();
  LoginActivity.start(baseActivity);
  baseActivity.finish();
}

Fixed version (ground truth):
@Override public void execute(Bundle bundle){
  LoginActivity.start(baseActivity);
  baseActivity.finish();
}
Program: 114605
Project: 114605
Buggy source:
@Override public void execute(Bundle bundle){
  QBUser user=(QBUser)bundle.getSerializable(QBServiceConsts.EXTRA_USER);
  App.getInstance().setUser(user);
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_SIGN_UP_INITIALIZED,true);
  MainActivity.start(SignUpActivity.this);
  finish();
}

Fixed version (ground truth):
@Override public void execute(Bundle bundle){
  QBUser user=(QBUser)bundle.getSerializable(QBServiceConsts.EXTRA_USER);
  App.getInstance().setUser(user);
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_SIGN_UP_INITIALIZED,true);
  DatabaseManager.clearAllCache(SignUpActivity.this);
  MainActivity.start(SignUpActivity.this);
  finish();
}
Program: 114606
Project: 114606
Buggy source:
@Override public void execute(Bundle bundle){
  QBUser user=(QBUser)bundle.getSerializable(QBServiceConsts.EXTRA_USER);
  App.getInstance().setUser(user);
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_IMPORT_INITIALIZED,true);
  MainActivity.start(SplashActivity.this);
  finish();
}

Fixed version (ground truth):
@Override public void execute(Bundle bundle){
  QBUser user=(QBUser)bundle.getSerializable(QBServiceConsts.EXTRA_USER);
  App.getInstance().setUser(user);
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_IMPORT_INITIALIZED,true);
  DatabaseManager.clearAllCache(SplashActivity.this);
  MainActivity.start(SplashActivity.this);
  finish();
}
Program: 114607
Project: 114607
Buggy source:
@Override public void onCounterFriendsChanged(int valueCounter){
  if (actionMode != null) {
    if (valueCounter == Consts.ZERO_VALUE) {
      closeWithoutRedirect=true;
      actionMode.finish();
      return;
    }
  }
 else {
    startAction();
  }
  countSelectedFriendsTextView.setText(valueCounter + "String_Node_Str");
}

Fixed version (ground truth):
@Override public void onCounterFriendsChanged(int valueCounter){
  if (actionMode != null) {
    if (valueCounter == Consts.ZERO_VALUE) {
      isNeedToCloseWithoutRedirect=true;
      actionMode.finish();
      return;
    }
  }
 else {
    startAction();
  }
  countSelectedFriendsTextView.setText(valueCounter + Consts.EMPTY_STRING);
}
Program: 114608
Project: 114608
Buggy source:
@Override public void onDestroyActionMode(ActionMode mode){
  if (!closeWithoutRedirect) {
    List<Friend> membersList=new ArrayList<Friend>(friendsAdapter.getSelectedFriends());
    Collections.sort(membersList,new SimpleComparator());
    GroupDialogActivity.start(activity,(ArrayList<Friend>)membersList);
    finish();
    actionMode=null;
    closeWithoutRedirect=false;
  }
 else {
    actionMode=null;
    closeWithoutRedirect=false;
  }
}

Fixed version (ground truth):
@Override public void onDestroyActionMode(ActionMode mode){
  if (isNeedToCloseWithoutRedirect) {
    isNeedToCloseWithoutRedirect=false;
    actionMode=null;
    finish();
  }
 else {
    isNeedToCloseWithoutRedirect=false;
    List<Friend> membersList=new ArrayList<Friend>(friendsAdapter.getSelectedFriends());
    Collections.sort(membersList,new SimpleComparator());
    GroupDialogActivity.start(activity,(ArrayList<Friend>)membersList);
    finish();
    actionMode=null;
  }
}
Program: 114609
Project: 114609
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case android.R.id.home:
    navigateToParent();
  return true;
}
return super.onOptionsItemSelected(item);
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case android.R.id.home:
    isNeedToCloseWithoutRedirect=true;
  navigateToParent();
return true;
}
return super.onOptionsItemSelected(item);
}
Program: 114610
Project: 114610
Buggy source:
public static void saveChatMessages(Context context,List<QBHistoryMessage> messagesList,String roomJidId,boolean isGroupMessage){
  for (  QBHistoryMessage historyMessage : messagesList) {
    String message=historyMessage.getBody();
    int senderId=historyMessage.getSenderId();
    String attachURL;
    if (TextUtils.isEmpty(message)) {
      attachURL=ChatUtils.getAttachUrlFromMessage(historyMessage.getAttachments());
    }
 else {
      attachURL=Consts.EMPTY_STRING;
    }
    if (TextUtils.isEmpty(message) && TextUtils.isEmpty(attachURL)) {
      if (isGroupMessage) {
        message=getMessageForNotification(context,senderId);
      }
 else {
        return;
      }
    }
    DialogMessageCache dialogMessageCache=new DialogMessageCache(roomJidId,senderId,message,attachURL,historyMessage.getDateSent());
    saveChatMessage(context,dialogMessageCache);
  }
}

Fixed version (ground truth):
public static void saveChatMessages(Context context,List<QBHistoryMessage> messagesList,String roomJidId,boolean isGroupMessage){
  for (  QBHistoryMessage historyMessage : messagesList) {
    String message=historyMessage.getBody();
    int senderId=historyMessage.getSenderId();
    String attachURL;
    if (TextUtils.isEmpty(message)) {
      attachURL=ChatUtils.getAttachUrlFromMessage(historyMessage.getAttachments());
    }
 else {
      attachURL=Consts.EMPTY_STRING;
    }
    if (TextUtils.isEmpty(message) && TextUtils.isEmpty(attachURL)) {
      if (isGroupMessage) {
        message=getMessageForNotification(context,senderId);
      }
 else {
        return;
      }
    }
    DialogMessageCache dialogMessageCache=new DialogMessageCache(roomJidId,senderId,message,attachURL,historyMessage.getDateSent(),true);
    saveChatMessage(context,dialogMessageCache);
  }
}
Program: 114611
Project: 114611
Buggy source:
public static void updateDialog(Context context,QBDialog dialog,String roomJidId){
  ContentResolver resolver=context.getContentResolver();
  ContentValues values=new ContentValues();
  values.put(DialogTable.Cols.COUNT_UNREAD_MESSAGES,getCountUnreadMessagesByDialog(context,dialog));
  values.put(DialogTable.Cols.LAST_MESSAGE,dialog.getLastMessage());
  values.put(DialogTable.Cols.LAST_DATE_SENT,dialog.getLastMessageDateSent());
  String condition=DialogTable.Cols.ROOM_JID_ID + "String_Node_Str" + roomJidId+ "String_Node_Str";
  resolver.update(DialogTable.CONTENT_URI,values,condition,null);
}

Fixed version (ground truth):
public static void updateDialog(Context context,String roomJidId,String lastMessage,long dateSent){
  ContentResolver resolver=context.getContentResolver();
  ContentValues values=new ContentValues();
  values.put(DialogTable.Cols.COUNT_UNREAD_MESSAGES,getCountUnreadMessagesByRoomJid(context,roomJidId));
  values.put(DialogTable.Cols.LAST_MESSAGE,lastMessage);
  values.put(DialogTable.Cols.LAST_DATE_SENT,dateSent);
  String condition=DialogTable.Cols.ROOM_JID_ID + "String_Node_Str" + roomJidId+ "String_Node_Str";
  resolver.update(DialogTable.CONTENT_URI,values,condition,null);
}
Program: 114612
Project: 114612
Buggy source:
public static void updateStatusMessage(Context context,String messageId,boolean isRead){
  ContentValues values=new ContentValues();
  String condition=DialogMessageTable.Cols.ID + "String_Node_Str" + messageId+ "String_Node_Str";
  ContentResolver resolver=context.getContentResolver();
  Cursor cursor=resolver.query(DialogMessageTable.CONTENT_URI,null,condition,null,null);
  if (cursor != null && cursor.getCount() > Consts.ZERO_INT_VALUE) {
    values.put(DialogMessageTable.Cols.IS_READ,isRead);
    resolver.update(DialogMessageTable.CONTENT_URI,values,condition,null);
    cursor.close();
  }
}

Fixed version (ground truth):
public static void updateStatusMessage(Context context,String messageId,boolean isRead){
  ContentValues values=new ContentValues();
  String condition=DialogMessageTable.Cols.ID + "String_Node_Str" + messageId+ "String_Node_Str";
  ContentResolver resolver=context.getContentResolver();
  Cursor cursor=resolver.query(DialogMessageTable.CONTENT_URI,null,condition,null,null);
  if (cursor != null && cursor.moveToFirst()) {
    String roomJidId=cursor.getString(cursor.getColumnIndex(DialogMessageTable.Cols.ROOM_JID_ID));
    String message=cursor.getString(cursor.getColumnIndex(DialogMessageTable.Cols.BODY));
    long time=cursor.getLong(cursor.getColumnIndex(DialogMessageTable.Cols.TIME));
    values.put(DialogMessageTable.Cols.IS_READ,isRead);
    resolver.update(DialogMessageTable.CONTENT_URI,values,condition,null);
    cursor.close();
    updateDialog(context,roomJidId,message,time);
  }
}
Program: 114613
Project: 114613
Buggy source:
public static void saveChatMessage(Context context,DialogMessageCache dialogMessageCache){
  ContentValues values=new ContentValues();
  values.put(DialogMessageTable.Cols.ROOM_JID_ID,dialogMessageCache.getRoomJidId());
  values.put(DialogMessageTable.Cols.SENDER_ID,dialogMessageCache.getSenderId());
  values.put(DialogMessageTable.Cols.BODY,dialogMessageCache.getMessage());
  values.put(DialogMessageTable.Cols.TIME,dialogMessageCache.getTime());
  values.put(DialogMessageTable.Cols.ATTACH_FILE_ID,dialogMessageCache.getAttachUrl());
  values.put(DialogMessageTable.Cols.IS_READ,false);
  context.getContentResolver().insert(DialogMessageTable.CONTENT_URI,values);
}

Fixed version (ground truth):
public static void saveChatMessage(Context context,DialogMessageCache dialogMessageCache){
  ContentValues values=new ContentValues();
  values.put(DialogMessageTable.Cols.ROOM_JID_ID,dialogMessageCache.getRoomJidId());
  values.put(DialogMessageTable.Cols.SENDER_ID,dialogMessageCache.getSenderId());
  values.put(DialogMessageTable.Cols.BODY,dialogMessageCache.getMessage());
  values.put(DialogMessageTable.Cols.TIME,dialogMessageCache.getTime());
  values.put(DialogMessageTable.Cols.ATTACH_FILE_ID,dialogMessageCache.getAttachUrl());
  values.put(DialogMessageTable.Cols.IS_READ,dialogMessageCache.isRead());
  context.getContentResolver().insert(DialogMessageTable.CONTENT_URI,values);
  updateDialog(context,dialogMessageCache.getRoomJidId(),dialogMessageCache.getMessage(),dialogMessageCache.getTime());
}
Program: 114614
Project: 114614
Buggy source:
public DialogMessageCache(String roomJidId,Integer senderId,String message,String attachUrl,long time){
  this.roomJidId=roomJidId;
  this.senderId=senderId;
  this.message=message;
  this.attachUrl=attachUrl;
  this.time=time;
}

Fixed version (ground truth):
public DialogMessageCache(String roomJidId,Integer senderId,String message,String attachUrl,long time,boolean isRead){
  this.roomJidId=roomJidId;
  this.senderId=senderId;
  this.message=message;
  this.attachUrl=attachUrl;
  this.time=time;
  this.isRead=isRead;
}
Program: 114615
Project: 114615
Buggy source:
public void sendPrivateMessage(String message) throws XMPPException, SmackException.NotConnectedException {
  QBChatMessage chatMessage=getQBChatMessage(message);
  privateChat.sendMessage(chatMessage);
  String roomJidId=opponentId + Consts.EMPTY_STRING;
  String attachUrl=Consts.EMPTY_STRING;
  long time=DateUtils.getCurrentTime();
  saveMessageToCache(new DialogMessageCache(roomJidId,user.getId(),chatMessage.getBody(),attachUrl,time));
}

Fixed version (ground truth):
public void sendPrivateMessage(String message) throws XMPPException, SmackException.NotConnectedException {
  QBChatMessage chatMessage=getQBChatMessage(message);
  privateChat.sendMessage(chatMessage);
  String roomJidId=opponentId + Consts.EMPTY_STRING;
  String attachUrl=Consts.EMPTY_STRING;
  long time=DateUtils.getCurrentTime();
  saveMessageToCache(new DialogMessageCache(roomJidId,user.getId(),chatMessage.getBody(),attachUrl,time,true));
}
Program: 114616
Project: 114616
Buggy source:
@Override public void processMessage(QBRoomChat roomChat,QBChatMessage chatMessage){
  Friend friend=DatabaseManager.getFriendById(context,chatMessage.getSenderId());
  String attachUrl=getAttachUrlIfExists(chatMessage);
  long time=Integer.parseInt(chatMessage.getProperty(propertyDateSent).toString());
  saveMessageToCache(new DialogMessageCache(roomChat.getJid(),chatMessage.getSenderId(),chatMessage.getBody(),attachUrl,time));
  if (!chatMessage.getSenderId().equals(user.getId())) {
    notifyMessageReceived(chatMessage,friend);
  }
}

Fixed version (ground truth):
@Override public void processMessage(QBRoomChat roomChat,QBChatMessage chatMessage){
  Friend friend=DatabaseManager.getFriendById(context,chatMessage.getSenderId());
  String attachUrl=getAttachUrlIfExists(chatMessage);
  long time=Integer.parseInt(chatMessage.getProperty(propertyDateSent).toString());
  saveMessageToCache(new DialogMessageCache(roomChat.getJid(),chatMessage.getSenderId(),chatMessage.getBody(),attachUrl,time,false));
  if (!chatMessage.getSenderId().equals(user.getId())) {
    notifyMessageReceived(chatMessage,friend);
  }
}
Program: 114617
Project: 114617
Buggy source:
public void updateDialog(QBDialog dialog,String roomJidId){
  DatabaseManager.updateDialog(context,dialog,roomJidId);
}

Fixed version (ground truth):
public void updateDialog(QBDialog dialog,String roomJidId){
  DatabaseManager.updateDialog(context,roomJidId,dialog.getLastMessage(),dialog.getLastMessageDateSent());
}
Program: 114618
Project: 114618
Buggy source:
public void sendPrivateMessageWithAttachImage(QBFile file) throws XMPPException, SmackException.NotConnectedException {
  QBChatMessage chatMessage=getQBChatMessageWithImage(file);
  privateChat.sendMessage(chatMessage);
  String roomJidId=opponentId + Consts.EMPTY_STRING;
  String attachUrl=file.getPublicUrl();
  long time=DateUtils.getCurrentTime();
  saveMessageToCache(new DialogMessageCache(roomJidId,user.getId(),chatMessage.getBody(),attachUrl,time));
}

Fixed version (ground truth):
public void sendPrivateMessageWithAttachImage(QBFile file) throws XMPPException, SmackException.NotConnectedException {
  QBChatMessage chatMessage=getQBChatMessageWithImage(file);
  privateChat.sendMessage(chatMessage);
  String roomJidId=opponentId + Consts.EMPTY_STRING;
  String attachUrl=file.getPublicUrl();
  long time=DateUtils.getCurrentTime();
  saveMessageToCache(new DialogMessageCache(roomJidId,user.getId(),chatMessage.getBody(),attachUrl,time,true));
}
Program: 114620
Project: 114620
Buggy source:
@Override public void bindView(View view,final Context context,Cursor cursor){
  final ViewHolder viewHolder=(ViewHolder)view.getTag();
  String avatarUrl;
  String body=cursor.getString(cursor.getColumnIndex(DialogMessageTable.Cols.BODY));
  String attachUrl=cursor.getString(cursor.getColumnIndex(DialogMessageTable.Cols.ATTACH_FILE_ID));
  int senderId=cursor.getInt(cursor.getColumnIndex(DialogMessageTable.Cols.SENDER_ID));
  long time=cursor.getLong(cursor.getColumnIndex(DialogMessageTable.Cols.TIME));
  viewHolder.attachImageView.setVisibility(View.GONE);
  if (isOwnMessage(senderId)) {
    avatarUrl=getAvatarUrlForCurrentUser();
  }
 else {
    avatarUrl=getAvatarUrlForFriend(opponentFriend);
  }
  if (!TextUtils.isEmpty(attachUrl)) {
    viewHolder.messageTextView.setVisibility(View.GONE);
    displayAttachImage(attachUrl,viewHolder.pleaseWaitTextView,viewHolder.attachImageView,viewHolder.progressBar);
  }
 else {
    viewHolder.messageTextView.setVisibility(View.VISIBLE);
    viewHolder.attachImageView.setVisibility(View.GONE);
    viewHolder.messageTextView.setText(body);
  }
  viewHolder.timeTextView.setText(DateUtils.longToMessageDate(time));
  if (dialog != null) {
    boolean isRead=cursor.getInt(cursor.getColumnIndex(DialogMessageTable.Cols.IS_READ)) > 0;
    if (!isRead) {
      String messageId=cursor.getString(cursor.getColumnIndex(DialogMessageTable.Cols.ID));
      QBUpdateStatusMessageCommand.start(context,messageId,true);
    }
  }
  displayAvatarImage(avatarUrl,viewHolder.avatarImageView);
}

Fixed version (ground truth):
@Override public void bindView(View view,final Context context,Cursor cursor){
  final ViewHolder viewHolder=(ViewHolder)view.getTag();
  String avatarUrl;
  String body=cursor.getString(cursor.getColumnIndex(DialogMessageTable.Cols.BODY));
  String attachUrl=cursor.getString(cursor.getColumnIndex(DialogMessageTable.Cols.ATTACH_FILE_ID));
  int senderId=cursor.getInt(cursor.getColumnIndex(DialogMessageTable.Cols.SENDER_ID));
  long time=cursor.getLong(cursor.getColumnIndex(DialogMessageTable.Cols.TIME));
  viewHolder.attachImageView.setVisibility(View.GONE);
  if (isOwnMessage(senderId)) {
    avatarUrl=getAvatarUrlForCurrentUser();
  }
 else {
    avatarUrl=getAvatarUrlForFriend(opponentFriend);
  }
  if (!TextUtils.isEmpty(attachUrl)) {
    viewHolder.messageTextView.setVisibility(View.GONE);
    displayAttachImage(attachUrl,viewHolder.pleaseWaitTextView,viewHolder.attachImageView,viewHolder.progressBar);
  }
 else {
    viewHolder.messageTextView.setVisibility(View.VISIBLE);
    viewHolder.attachImageView.setVisibility(View.GONE);
    viewHolder.messageTextView.setText(body);
  }
  viewHolder.timeTextView.setText(DateUtils.longToMessageDate(time));
  boolean isRead=cursor.getInt(cursor.getColumnIndex(DialogMessageTable.Cols.IS_READ)) > Consts.ZERO_INT_VALUE;
  if (dialog != null && !isRead) {
    String messageId=cursor.getString(cursor.getColumnIndex(DialogMessageTable.Cols.ID));
    QBUpdateStatusMessageCommand.start(context,messageId,true);
  }
  displayAvatarImage(avatarUrl,viewHolder.avatarImageView);
}
Program: 114621
Project: 114621
Buggy source:
private void saveChanges(final String fullname,final String email) throws IOException {
  if (!isUserDataCorrect()) {
    DialogUtils.showLong(this,getString(R.string.dlg_not_all_fields_entered));
    return;
  }
  showProgress();
  user.setFullName(fullname);
  user.setEmail(email);
  if (isNeedUpdateAvatar) {
    new ReceiveImageFileTask(this).execute(imageHelper,avatarBitmapCurrent,true);
  }
 else {
    String status=statusMessageEditText.getText().toString();
    QBUpdateUserCommand.start(this,user,null,status);
  }
}

Fixed version (ground truth):
private void saveChanges(final String fullname,final String email) throws IOException {
  if (!isUserDataCorrect()) {
    DialogUtils.showLong(this,getString(R.string.dlg_not_all_fields_entered));
    return;
  }
  showProgress();
  App.getInstance().getPrefsHelper().savePref(PrefsHelper.PREF_REMEMBER_ME,false);
  user.setFullName(fullname);
  user.setEmail(email);
  if (isNeedUpdateAvatar) {
    new ReceiveImageFileTask(this).execute(imageHelper,avatarBitmapCurrent,true);
  }
 else {
    String status=statusMessageEditText.getText().toString();
    QBUpdateUserCommand.start(this,user,null,status);
  }
}
Program: 114622
Project: 114622
Buggy source:
public void loginWithFacebook(){
  Session session=Session.getActiveSession();
  if (!session.isOpened() && !session.isClosed()) {
    session.openForRead(new Session.OpenRequest(activity).setCallback(facebookStatusCallback));
  }
 else {
    Session.openActiveSession(activity,true,facebookStatusCallback);
  }
}

Fixed version (ground truth):
public void loginWithFacebook(){
  TipsManager.setIsJustLogined(true);
  Session session=Session.getActiveSession();
  if (!session.isOpened() && !session.isClosed()) {
    session.openForRead(new Session.OpenRequest(activity).setCallback(facebookStatusCallback));
  }
 else {
    Session.openActiveSession(activity,true,facebookStatusCallback);
  }
}
Program: 114623
Project: 114623
Buggy source:
public static void saveDialog(Context context,QBDialog dialog){
  ContentValues values=getContentValuesDialogTable(dialog);
  String condition=DialogTable.Cols.DIALOG_ID + "String_Node_Str" + dialog.getDialogId()+ "String_Node_Str";
  ContentResolver resolver=context.getContentResolver();
  Cursor cursor=resolver.query(DialogTable.CONTENT_URI,null,condition,null,null);
  if (cursor != null && cursor.getCount() > Consts.ZERO_VALUE) {
    resolver.update(DialogTable.CONTENT_URI,values,condition,null);
  }
 else {
    resolver.insert(DialogTable.CONTENT_URI,values);
  }
}

Fixed version (ground truth):
public static void saveDialog(Context context,QBDialog dialog,String roomJidId){
  unreadMessagesCount=Consts.ZERO_VALUE;
  ContentValues values;
  String condition=DialogTable.Cols.ROOM_JID_ID + "String_Node_Str" + roomJidId+ "String_Node_Str";
  ContentResolver resolver=context.getContentResolver();
  Cursor cursor=resolver.query(DialogTable.CONTENT_URI,null,condition,null,null);
  if (cursor != null && cursor.getCount() > Consts.ZERO_VALUE) {
    values=getContentValuesForUpdateDialogTable(dialog);
    resolver.update(DialogTable.CONTENT_URI,values,condition,null);
  }
 else {
    values=getContentValuesForCreateDialogTable(dialog,roomJidId);
    resolver.insert(DialogTable.CONTENT_URI,values);
  }
}
Program: 114624
Project: 114624
Buggy source:
public static void saveChatMessage(Context context,DialogMessageCache dialogMessageCache){
  ContentValues values=new ContentValues();
  values.put(DialogMessageTable.Cols.ROOM_JID_ID,dialogMessageCache.getRoomJidId());
  values.put(DialogMessageTable.Cols.SENDER_ID,dialogMessageCache.getSenderId());
  values.put(DialogMessageTable.Cols.BODY,dialogMessageCache.getMessage());
  values.put(DialogMessageTable.Cols.TIME,System.currentTimeMillis());
  values.put(DialogMessageTable.Cols.ATTACH_FILE_ID,dialogMessageCache.getAttachUrl());
  context.getContentResolver().insert(DialogMessageTable.CONTENT_URI,values);
}

Fixed version (ground truth):
public static void saveChatMessage(Context context,DialogMessageCache dialogMessageCache){
  unreadMessagesCount++;
  ContentValues values=new ContentValues();
  values.put(DialogMessageTable.Cols.ROOM_JID_ID,dialogMessageCache.getRoomJidId());
  values.put(DialogMessageTable.Cols.SENDER_ID,dialogMessageCache.getSenderId());
  values.put(DialogMessageTable.Cols.BODY,dialogMessageCache.getMessage());
  values.put(DialogMessageTable.Cols.TIME,System.currentTimeMillis());
  values.put(DialogMessageTable.Cols.ATTACH_FILE_ID,dialogMessageCache.getAttachUrl());
  context.getContentResolver().insert(DialogMessageTable.CONTENT_URI,values);
  updateUnreadMessagesCount(context,dialogMessageCache.getRoomJidId(),dialogMessageCache.getMessage());
}
Program: 114625
Project: 114625
Buggy source:
public static void saveDialogs(Context context,List<QBDialog> dialogsList){
  for (  QBDialog dialog : dialogsList) {
    saveDialog(context,dialog);
  }
}

Fixed version (ground truth):
public static void saveDialogs(Context context,List<QBDialog> dialogsList){
  for (  QBDialog dialog : dialogsList) {
    if (dialog.getType().equals(QBDialogType.PRIVATE)) {
      String roomJidId=ChatUtils.getOccupantIdFromList(dialog.getOccupants()) + Consts.EMPTY_STRING;
      saveDialog(context,dialog,roomJidId);
    }
 else {
      saveDialog(context,dialog,dialog.getRoomJid());
    }
  }
}
Program: 114626
Project: 114626
Buggy source:
public static void start(Context context,Object chatId,String lastMessage,int countMessage){
  Intent intent=new Intent(QBServiceConsts.UPDATE_CHAT_DIALOG_ACTION,null,context,QBService.class);
  intent.putExtra(QBServiceConsts.EXTRA_ROOM_JID_ID,(java.io.Serializable)chatId);
  intent.putExtra(QBServiceConsts.EXTRA_LAST_CHAT_MESSAGE,lastMessage);
  intent.putExtra(QBServiceConsts.EXTRA_DIALOG_COUNT_UNREAD_MESSAGE,countMessage);
  context.startService(intent);
}

Fixed version (ground truth):
public static void start(Context context,QBDialog dialog,String roomJidId){
  Intent intent=new Intent(QBServiceConsts.UPDATE_CHAT_DIALOG_ACTION,null,context,QBService.class);
  intent.putExtra(QBServiceConsts.EXTRA_ROOM_JID_ID,roomJidId);
  intent.putExtra(QBServiceConsts.EXTRA_DIALOG,dialog);
  context.startService(intent);
}
Program: 114627
Project: 114627
Buggy source:
@Override public Bundle perform(Bundle extras) throws Exception {
  Object chatId=extras.getInt(QBServiceConsts.EXTRA_ROOM_JID_ID);
  String lastMessage=extras.getString(QBServiceConsts.EXTRA_LAST_CHAT_MESSAGE);
  int countMessage=extras.getInt(QBServiceConsts.EXTRA_DIALOG_COUNT_UNREAD_MESSAGE);
  return null;
}

Fixed version (ground truth):
@Override public Bundle perform(Bundle extras) throws Exception {
  QBDialog dialog=(QBDialog)extras.getSerializable(QBServiceConsts.EXTRA_DIALOG);
  String roomJidId=extras.getString(QBServiceConsts.EXTRA_ROOM_JID_ID);
  chatHelper.updateLoadedChatDialog(dialog,roomJidId);
  return null;
}
Program: 114628
Project: 114628
Buggy source:
public QBDialog createRoomChat(String roomName,List<Integer> friendIdsList) throws SmackException, XMPPException, QBResponseException {
  ArrayList<Integer> occupantIdsList=ChatUtils.getOccupantIdsWithUserList(friendIdsList);
  QBDialog dialog=roomChatManager.createDialog(roomName,QBDialogType.GROUP,occupantIdsList);
  joinRoomChat(dialog.getRoomJid());
  inviteFriendsToRoom(dialog,friendIdsList);
  saveDialogToCache(dialog);
  return dialog;
}

Fixed version (ground truth):
public QBDialog createRoomChat(String roomName,List<Integer> friendIdsList) throws SmackException, XMPPException, QBResponseException {
  ArrayList<Integer> occupantIdsList=ChatUtils.getOccupantIdsWithUserList(friendIdsList);
  QBDialog dialog=roomChatManager.createDialog(roomName,QBDialogType.GROUP,occupantIdsList);
  joinRoomChat(dialog.getRoomJid());
  inviteFriendsToRoom(dialog,friendIdsList);
  saveDialogToCache(dialog,dialog.getRoomJid());
  return dialog;
}
Program: 114629
Project: 114629
Buggy source:
private void processIfInvitationToRoomMessage(Friend sender,QBChatMessage chatMessage){
  if (ChatUtils.isNotificationMessage(chatMessage)) {
    QBDialog dialog=ChatUtils.parseDialogFromMessage(chatMessage);
    tryJoinRoomChat(dialog.getRoomJid());
    saveDialogToCache(dialog);
    String message=context.getResources().getString(R.string.user_created_room,sender.getFullname(),dialog.getName());
    chatMessage.setBody(message);
  }
}

Fixed version (ground truth):
private void processIfInvitationToRoomMessage(Friend sender,QBChatMessage chatMessage){
  if (ChatUtils.isNotificationMessage(chatMessage)) {
    QBDialog dialog=ChatUtils.parseDialogFromMessage(chatMessage);
    tryJoinRoomChat(dialog.getRoomJid());
    saveDialogToCache(dialog,dialog.getRoomJid());
    String message=context.getResources().getString(R.string.user_created_room,sender.getFullname(),dialog.getName());
    chatMessage.setBody(message);
  }
}
Program: 114630
Project: 114630
Buggy source:
private void saveDialogToCache(QBDialog dialog){
  DatabaseManager.saveDialog(context,dialog);
}

Fixed version (ground truth):
private void saveDialogToCache(QBDialog dialog,String roomJidId){
  DatabaseManager.saveDialog(context,dialog,roomJidId);
}
Program: 114631
Project: 114631
Buggy source:
private void startUpdateChatDialog(){
  Cursor cursor=(Cursor)messagesAdapter.getItem(messagesAdapter.getCount() - 1);
  String lastMessage=cursor.getString(cursor.getColumnIndex(DialogMessageTable.Cols.BODY));
  QBUpdateDialogCommand.start(this,roomJidId,lastMessage,Consts.ZERO_VALUE);
}

Fixed version (ground truth):
private void startUpdateChatDialog(){
  QBUpdateDialogCommand.start(this,getQBDialog(),roomJidId);
}
Program: 114632
Project: 114632
Buggy source:
private static UriMatcher buildUriMatcher(){
  final UriMatcher matcher=new UriMatcher(UriMatcher.NO_MATCH);
  matcher.addURI(AUTHORITY,FriendTable.PATH,FriendTable.PATH_TOKEN);
  matcher.addURI(AUTHORITY,ChatMessagesTable.PATH,ChatMessagesTable.PATH_TOKEN);
  return matcher;
}

Fixed version (ground truth):
private static UriMatcher buildUriMatcher(){
  final UriMatcher matcher=new UriMatcher(UriMatcher.NO_MATCH);
  matcher.addURI(AUTHORITY,FriendTable.PATH,FriendTable.PATH_TOKEN);
  matcher.addURI(AUTHORITY,ChatMessageTable.PATH,ChatMessageTable.PATH_TOKEN);
  matcher.addURI(AUTHORITY,ChatTable.PATH,ChatTable.PATH_TOKEN);
  return matcher;
}
Program: 114633
Project: 114633
Buggy source:
@Override public void onCreate(SQLiteDatabase db){
  createFriendTable(db);
  createChatMessageTable(db);
}

Fixed version (ground truth):
@Override public void onCreate(SQLiteDatabase db){
  createFriendTable(db);
  createChatMessageTable(db);
  createChatTable(db);
}
Program: 114634
Project: 114634
Buggy source:
@Override public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){
  dropTable(db,FriendTable.TABLE_NAME);
  dropTable(db,ChatMessagesTable.TABLE_NAME);
  onCreate(db);
}

Fixed version (ground truth):
@Override public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){
  dropTable(db,FriendTable.TABLE_NAME);
  dropTable(db,ChatMessageTable.TABLE_NAME);
  dropTable(db,ChatTable.TABLE_NAME);
  onCreate(db);
}
Program: 114635
Project: 114635
Buggy source:
private void createChatMessageTable(SQLiteDatabase db){
  StringBuilder privateChatMessagesTableFields=new StringBuilder();
  privateChatMessagesTableFields.append(ChatMessagesTable.Cols.ID).append("String_Node_Str").append(ChatMessagesTable.Cols.BODY).append("String_Node_Str").append(ChatMessagesTable.Cols.SENDER_ID).append("String_Node_Str").append(ChatMessagesTable.Cols.TIME).append("String_Node_Str").append(ChatMessagesTable.Cols.GROUP_ID).append("String_Node_Str").append(ChatMessagesTable.Cols.SENDER_NAME).append("String_Node_Str").append(ChatMessagesTable.Cols.OPPONENT_NAME).append("String_Node_Str").append(ChatMessagesTable.Cols.ATTACH_FILE_ID).append("String_Node_Str").append(ChatMessagesTable.Cols.CHAT_ID).append("String_Node_Str");
  createTable(db,ChatMessagesTable.TABLE_NAME,privateChatMessagesTableFields.toString());
}

Fixed version (ground truth):
private void createChatMessageTable(SQLiteDatabase db){
  StringBuilder chatMessageTableFields=new StringBuilder();
  chatMessageTableFields.append(ChatMessageTable.Cols.ID).append("String_Node_Str").append(ChatMessageTable.Cols.BODY).append("String_Node_Str").append(ChatMessageTable.Cols.SENDER_ID).append("String_Node_Str").append(ChatMessageTable.Cols.TIME).append("String_Node_Str").append(ChatMessageTable.Cols.GROUP_ID).append("String_Node_Str").append(ChatMessageTable.Cols.ATTACH_FILE_ID).append("String_Node_Str").append(ChatMessageTable.Cols.CHAT_ID).append("String_Node_Str");
  createTable(db,ChatMessageTable.TABLE_NAME,chatMessageTableFields.toString());
}
Program: 114636
Project: 114636
Buggy source:
public static void deleteAllChats(Context context){
  context.getContentResolver().delete(ChatMessagesTable.CONTENT_URI,null,null);
}

Fixed version (ground truth):
public static void deleteAllChats(Context context){
  context.getContentResolver().delete(ChatTable.CONTENT_URI,null,null);
}
Program: 114637
Project: 114637
Buggy source:
public static void deleteMessagesByChatId(Context context,int chatId){
  context.getContentResolver().delete(ChatMessagesTable.CONTENT_URI,ChatMessagesTable.Cols.CHAT_ID + "String_Node_Str" + chatId,null);
}

Fixed version (ground truth):
public static void deleteMessagesByChatId(Context context,int chatId){
  context.getContentResolver().delete(ChatMessageTable.CONTENT_URI,ChatMessageTable.Cols.CHAT_ID + "String_Node_Str" + chatId,null);
}
Program: 114638
Project: 114638
Buggy source:
public static void saveFriend(Context context,Friend friend){
  ContentValues values=getContentValues(friend);
  String condition=FriendTable.Cols.ID + "String_Node_Str" + friend.getId()+ "String_Node_Str";
  ContentResolver resolver=context.getContentResolver();
  Cursor cursor=resolver.query(FriendTable.CONTENT_URI,null,condition,null,null);
  if (cursor != null && cursor.getCount() > Consts.ZERO_VALUE) {
    resolver.update(FriendTable.CONTENT_URI,values,condition,null);
  }
 else {
    resolver.insert(FriendTable.CONTENT_URI,values);
  }
}

Fixed version (ground truth):
public static void saveFriend(Context context,Friend friend){
  ContentValues values=getContentValuesFriendTable(friend);
  String condition=FriendTable.Cols.ID + "String_Node_Str" + friend.getId()+ "String_Node_Str";
  ContentResolver resolver=context.getContentResolver();
  Cursor cursor=resolver.query(FriendTable.CONTENT_URI,null,condition,null,null);
  if (cursor != null && cursor.getCount() > Consts.ZERO_VALUE) {
    resolver.update(FriendTable.CONTENT_URI,values,condition,null);
  }
 else {
    resolver.insert(FriendTable.CONTENT_URI,values);
  }
}
Program: 114639
Project: 114639
Buggy source:
public static void deleteMessagesByGroupId(Context context,String groupId){
  context.getContentResolver().delete(ChatMessagesTable.CONTENT_URI,ChatMessagesTable.Cols.GROUP_ID + "String_Node_Str" + groupId+ "String_Node_Str",null);
}

Fixed version (ground truth):
public static void deleteMessagesByGroupId(Context context,String groupId){
  context.getContentResolver().delete(ChatMessageTable.CONTENT_URI,ChatMessageTable.Cols.GROUP_ID + "String_Node_Str" + groupId+ "String_Node_Str",null);
}
Program: 114640
Project: 114640
Buggy source:
public static void saveChatMessage(Context context,ChatMessageCache chatMessageCache){
  ContentValues values=new ContentValues();
  values.put(ChatMessagesTable.Cols.BODY,chatMessageCache.getMessage());
  values.put(ChatMessagesTable.Cols.SENDER_ID,chatMessageCache.getSenderId());
  values.put(ChatMessagesTable.Cols.TIME,System.currentTimeMillis());
  values.put(ChatMessagesTable.Cols.ATTACH_FILE_ID,chatMessageCache.getAttachUrl());
  if (chatMessageCache.getRoomJid() != null) {
    values.put(ChatMessagesTable.Cols.GROUP_ID,chatMessageCache.getRoomJid());
  }
 else   if (chatMessageCache.getChatId() != null) {
    values.put(ChatMessagesTable.Cols.CHAT_ID,chatMessageCache.getChatId());
  }
  context.getContentResolver().insert(ChatMessagesTable.CONTENT_URI,values);
}

Fixed version (ground truth):
public static void saveChatMessage(Context context,ChatMessageCache chatMessageCache){
  ContentValues values=new ContentValues();
  values.put(ChatMessageTable.Cols.BODY,chatMessageCache.getMessage());
  values.put(ChatMessageTable.Cols.SENDER_ID,chatMessageCache.getSenderId());
  values.put(ChatMessageTable.Cols.TIME,System.currentTimeMillis());
  values.put(ChatMessageTable.Cols.ATTACH_FILE_ID,chatMessageCache.getAttachUrl());
  if (chatMessageCache.getRoomJid() != null) {
    values.put(ChatMessageTable.Cols.GROUP_ID,chatMessageCache.getRoomJid());
  }
 else   if (chatMessageCache.getChatId() != null) {
    values.put(ChatMessageTable.Cols.CHAT_ID,chatMessageCache.getChatId());
  }
  context.getContentResolver().insert(ChatMessageTable.CONTENT_URI,values);
}
Program: 114641
Project: 114641
Buggy source:
public static Cursor getAllPrivateChatMessagesByChatId(Context context,int chatId){
  return context.getContentResolver().query(ChatMessagesTable.CONTENT_URI,null,ChatMessagesTable.Cols.CHAT_ID + "String_Node_Str" + chatId,null,null);
}

Fixed version (ground truth):
public static Cursor getAllPrivateChatMessagesByChatId(Context context,int chatId){
  return context.getContentResolver().query(ChatMessageTable.CONTENT_URI,null,ChatMessageTable.Cols.CHAT_ID + "String_Node_Str" + chatId,null,null);
}
Program: 114642
Project: 114642
Buggy source:
public static Cursor getAllGroupChatMessagesByGroupId(Context context,String groupId){
  return context.getContentResolver().query(ChatMessagesTable.CONTENT_URI,null,ChatMessagesTable.Cols.GROUP_ID + "String_Node_Str" + "String_Node_Str"+ groupId+ "String_Node_Str",null,null);
}

Fixed version (ground truth):
public static Cursor getAllGroupChatMessagesByGroupId(Context context,String groupId){
  return context.getContentResolver().query(ChatMessageTable.CONTENT_URI,null,ChatMessageTable.Cols.GROUP_ID + "String_Node_Str" + "String_Node_Str"+ groupId+ "String_Node_Str",null,null);
}