Buggy code:
public class RecordEditActivity extends PreferenceActivity implements DatePickerDialog . OnDateSetListener , TimePickerDialog . OnTimeSetListener { private String TAG = "capture" ; private Context mContext ; private CheckBoxPreference mAlarmPref ; private EditTextPreference mNamePref ; private EditTextPreference mDespPref ; private ListPreference mPeriodPref ; private Preference mTimePref ; private Preference mCountPref ; private Preference mCreatedatePref ; private MainApp mMainApp ; private RecordsDBAdapter mRecordsDBAdapter ; private long mRowId = - 1 ; private String mName = "" ; private String mDesp = "" ; private boolean mAlarmOn = false ; private int mPeriodType = - 1 ; private SimpleDate mDate = null ; private int mPeriod = - 1 ; private SimpleDate mTime = null ; private int mCount ; private SimpleDate mCreateDate = null ; private boolean mEditMode = false ; @ Override protected void onCreate ( Bundle savedInstanceState ) { } private void initalPrefs ( ) { } private void setCtrlBar ( ) { } @ Override public boolean onPreferenceTreeClick ( PreferenceScreen preferenceScreen , Preference preference ) { } public void onTimeSet ( TimePicker view , int hourOfDay , int minute ) { } public void onDateSet ( DatePicker view , int year , int monthOfYear , int dayOfMonth ) { } public boolean isNumber ( String s ) { } public void createNewRecord ( ) { String errormsg = "" ; if ( ( mName . length ( ) ) == 0 ) { errormsg = "Please<seq2seq4repair_space>naming<seq2seq4repair_space>your<seq2seq4repair_space>new<seq2seq4repair_space>record" ; } else if ( ( mRecordsDBAdapter . checkRecordByName ( mName ) ) == true ) { if ( ! ( mEditMode ) ) errormsg = ( "Record<seq2seq4repair_space>with<seq2seq4repair_space>name<seq2seq4repair_space>" + ( mName ) ) + "<seq2seq4repair_space>exists.<seq2seq4repair_space>Please<seq2seq4repair_space>choose<seq2seq4repair_space>another<seq2seq4repair_space>name<seq2seq4repair_space>for<seq2seq4repair_space>your<seq2seq4repair_space>new<seq2seq4repair_space>record" ; } else if ( ( ( mAlarmOn ) == true ) && ( ( mPeriodType ) == ( - 1 ) ) ) { errormsg = "You<seq2seq4repair_space>have<seq2seq4repair_space>turned<seq2seq4repair_space>alarm<seq2seq4repair_space>on.<seq2seq4repair_space>Please<seq2seq4repair_space>choose<seq2seq4repair_space>your<seq2seq4repair_space>alarm<seq2seq4repair_space>repeat<seq2seq4repair_space>period" ; } else if ( ( ( ( mAlarmOn ) == true ) && ( ( mPeriodType ) == 8 ) ) && ( ( mPeriod ) == ( - 1 ) ) ) { errormsg = "Please<seq2seq4repair_space>specify<seq2seq4repair_space>your<seq2seq4repair_space>alarm<seq2seq4repair_space>repeat<seq2seq4repair_space>period" ; } else if ( ( ( ( mAlarmOn ) == true ) && ( ( mPeriodType ) == 9 ) ) && ( ( mDate ) == null ) ) { errormsg = "Please<seq2seq4repair_space>specify<seq2seq4repair_space>your<seq2seq4repair_space>alarm<seq2seq4repair_space>repeat<seq2seq4repair_space>date" ; } else if ( ( ( mAlarmOn ) == true ) && ( ( mTime ) == null ) ) { errormsg = "Please<seq2seq4repair_space>specify<seq2seq4repair_space>your<seq2seq4repair_space>alarm<seq2seq4repair_space>repeat<seq2seq4repair_space>time" ; } if ( ( errormsg . length ( ) ) > 0 ) { AlertDialog . Builder builder = new AlertDialog . Builder ( mContext ) ; builder . setMessage ( errormsg ) . setCancelable ( false ) . setPositiveButton ( "OK" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int id ) { } } ) ; AlertDialog alert = builder . create ( ) ; alert . show ( ) ; } else { Calendar c = Calendar . getInstance ( ) ; if ( ( mDate ) == null ) { mDate = new SimpleDate ( c . get ( Calendar . YEAR ) , c . get ( Calendar . MONTH ) , c . get ( Calendar . DAY_OF_MONTH ) ) ; } if ( ( mTime ) == null ) { mTime = new SimpleDate ( c . get ( Calendar . HOUR ) , c . get ( Calendar . MINUTE ) ) ; } if ( mEditMode ) <START_BUG> mRecordsDBAdapter . updateRecord ( mRowId , mName , mDesp , mAlarmOn , mPeriodType , mPeriod , mDate . getDateString ( ) , mTime . getTimeString ( ) , 0 , "" ) ; <END_BUG> else { long id = mRecordsDBAdapter . insertRecord ( mName , mDesp , mAlarmOn , mPeriodType , mPeriod , mDate . getDateString ( ) , mTime . getTimeString ( ) , 0 , "" , mCreateDate . getFullString ( ) ) ; if ( ( id >= 0 ) && ( ( mRecordsDBAdapter . IsPhotoTableExist ( id ) ) == false ) ) { mRecordsDBAdapter . createNewPhotoTable ( id ) ; } } } } private void populateFields ( ) { } public void setAlarm ( ) { } @ Override protected void onPause ( ) { } @ Override protected void onResume ( ) { } }

Fix:
mRecordsDBAdapter . updateRecord ( mRowId , mName , mDesp , mAlarmOn , mPeriodType , mPeriod , mDate . getDateString ( ) , mTime . getTimeString ( ) ) ;