title: Android updating database record always returns zero
body: <p>My Update method in DataBaseHandler Class</p>
  
  <pre><code>    public void updateProject(Project project){
           SQLiteDatabase db = this.getWritableDatabase();
           ContentValues values = new ContentValues();
           values.put(PROJECT_NAME, project.getName()); // Contact Name
           values.put(PROJECT_DESCRIPTION, project.getDescription()); // Contact Phone
           values.put(CLIENT_NAME, project.getClient_name());
           values.put(LOCATION, project.getLocation());
           String where = PROJECT_ID + " = ? ";       
           String [] value = { String.valueOf(project.getProject_id()) };
           try{
               int count = db.update(TABLE_PROJECT, values, where , value);
               Log.d(LOG_TAG, "Updated rows -&gt; " + count);
           }catch (Exception e) {
              e.printStackTrace();
          }
          db.close();
      }
  }
  </code></pre>
  
  <p>The java bean class</p>
  
  <pre><code>public class Project implements Serializable{
  
      private static final long serialVersionUID = 1L;
      private int project_id;
      private String name;
      private String description;
      private String client_name;
      private String location;
  
      public Project(){
  
      }
  
      public Project(int project_id, String name, String client_name,String description, String location){
          this.project_id = project_id;
          this.name = name;
          this.description = description;
          this.client_name = client_name;
          this.location = location;
      }
  
      public int getProject_id() {
          return project_id;
      }
  
      public void setProject_id(int project_id) {
          this.project_id = project_id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public String getClient_name() {
          return client_name;
      }
  
      public void setClient_name(String client_name) {
          this.client_name = client_name;
      }
  
      public String getLocation() {
          return location;
      }
  
      public void setLocation(String location) {
          this.location = location;
      }
  
  }
  </code></pre>
  
  <p>The activity which adds and updates the project item from list view</p>
  
  <pre><code>public class AddProjectActivity extends Activity implements Serializable{
  
      private static final long serialVersionUID = 1L;
      private MenuItem saveItem;
      private DatabaseHandler dbHelper;
      private static final String TITLE = "Add Project";
      public boolean isEdit = false;
      private static final String LOG_TAG = "debugger";
      private Project editedProject;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.add_project);
          setTitle(TITLE);
          dbHelper = DatabaseHandler.getInstance(this);           
  
          //get intent from Project Fragment when project is edited
          Intent intent = getIntent();
          if(intent.hasExtra(IntentConstants.PROJECT_ITEM)){
              Project project = (Project) intent.getSerializableExtra(IntentConstants.PROJECT_ITEM);
              if(project != null){
                  this.isEdit = true;
                  setEditedProject(project);
                  setProjectData(project);
              }
          }
      }          
  
  
  
      private void setProjectData(Project project){
          EditText projectName = (EditText) findViewById(R.id.editTextProjectName);
          projectName.setText(project.getName());
          EditText clientName = (EditText) findViewById(R.id.editTextProjectClient);
          clientName.setText(project.getClient_name());
          EditText projectDesc = (EditText) findViewById(R.id.editTextProjectDesc);
          projectDesc.setText(project.getDescription());
          EditText projectLocation = (EditText) findViewById(R.id.editTextProjectLocation);
          projectLocation.setText(project.getLocation());
      }
  
  
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
        case R.id.saveButton:
             if(isEdit == true){
                updateProject();
             }else{
                saveProject();
             }
             finish();
          break;
       case R.id.cancelButton:
          finish();
          break;
       default:
          break;
      }
   return true;
  }
  
      private void updateProject(){
        dbHelper.updateProject(getProjectData(getEditedProject()));
      }
  
      public boolean isEdit() {
          return isEdit;
      }
  
      public void setEdit(boolean isEdit) {
          this.isEdit = isEdit;
      }
  
      private Project getProjectData(Project newProject){
          EditText projectName = (EditText) findViewById(R.id.editTextProjectName);
          String project = projectName.getText().toString();
          EditText clientName = (EditText) findViewById(R.id.editTextProjectClient);
          String client = clientName.getText().toString();
          EditText projectDesc = (EditText) findViewById(R.id.editTextProjectDesc);
          String description = projectDesc.getText().toString();
          EditText projectLocation = (EditText) findViewById(R.id.editTextProjectLocation);
          String location = projectLocation.getText().toString();
  
          newProject.setName(project);
          newProject.setClient_name(client);
          newProject.setDescription(description);
          newProject.setLocation(location);
          return newProject;
      }
  
      public Project getEditedProject() {
          return editedProject;
      }
  
      public void setEditedProject(Project editedProject) {
          this.editedProject = editedProject;
      }
  
  }
  </code></pre>
  
  <p>My <code>ListFragment</code> method that handles the click of listview item. It passes the data to <code>AddProjectActivity</code> using <code>Intent</code></p>
  
  <pre><code>@Override
      public void onListItemClick(ListView l, View v, int position, long id) {
          super.onListItemClick(l, v, position, id);
          if(dbHelper != null){
              Project project = (Project) this.getListAdapter().getItem(position);
              Intent intent = new Intent(getActivity(), AddProjectActivity.class);
              intent.putExtra(IntentConstants.PROJECT_ITEM, project);
              startActivity(intent);
              this.isEdit = true;
          }
      }
  </code></pre>
  
  <p>The problem I have is when listview item is edited and updated by user it never gets updated in database. The rowcount returned by update method is always zero. </p>
  
  <p>I am not able to fix this issue. </p>
  
  <p>Can someone help please.</p>