title: android sqlite query error
body: <p>I have this code to check if the values of (lang) and (lat) exist or not. If they don't exist the program crashed instead of the function returning true. Why?</p>
  
  <pre><code>public boolean pointNotExist(int lat, int lang)
  {
      Cursor r= db.query(DATABASE_TABLE3, new String[] {
                      "_id",
                      "point_name",
                      "point_langtitude",
                      "point_latitude",
                      "No_of_visits"
                      }, 
                  "point_langtitude"+"=" +lang+ " and " +"point_latitude"+ "="+lat,
                  null, 
                  null, 
                  null, 
                  null);
      if(r==null)
      {
          r.close();
          return true;
      }
      else 
      {
          r.moveToFirst();
          ContentValues args = new ContentValues();
          args.put("No_of_visits", 7);
          boolean d=db.update(DATABASE_TABLE3, args, 
          "_id"  + "=" + r.getInt(0), null) &gt; 0;
          return false;
      }
  }
  </code></pre>
  
  <p>This is the logCat : </p>
  
  <pre><code>ERROR/Database(32321): 
      Error inserting points_counter=2 point_langtitude=-10084093 _id=16 point_latitude=37422005 
  ERROR/Database(32321):   
      android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
  </code></pre>
  
  <p>The inserting Points_Counter is a counter in another class and when this counter =2 this (pointNotExist) function invoked.<br>
  <em>The problem occurred before else statement.</em></p>
  
  <p>This is the inserting code: </p>
  
  <pre><code>public void insertPointOfIntrest(int lat, int lang,String name)
  { 
      ContentValues initialValues = new ContentValues(); 
      initialValues.put("point_langtitude", lang); 
      initialValues.put("point_latitude", lat); 
      initialValues.put("point_name", name); 
      initialValues.put("No_of_visits",1); 
      db.insert(DATABASE_TABLE3, null, initialValues); 
  }
  </code></pre>
  
  <p>This is the creating table code: </p>
  
  <pre><code>//creating table 
  track_pointOfInterest db.execSQL(
          "create table pointOfIntrest (_id integer primary key autoincrement, " 
          +"point_name text," 
          + "point_langtitude integer, point_latitude integer, " 
          + "No_of_visits );"
      );
  </code></pre>