title: Insert Integer Value in Sqlite android
body: <p>I m trying to insert Integer value but its can't accept the values.its take second String value and give Exception of datatype</p>
  
  <p>this is my inserting code
  </p>
  
  <pre><code>void addCategory(Category Category) {
      SQLiteDatabase db = this.getWritableDatabase();
  
      ContentValues values = new ContentValues();
      values.put(KEY_IMG, Category.getimg()); // Category Name
      values.put(KEY_NAME, Category.getName()); // Category Name
      values.put(KEY_SELECTION, Category.isSelected()); // Category Phone
  
      // Inserting Row
      db.insert(TABLE_CategoryS, null, values);
      db.close(); // Closing database connection
  }
  </code></pre>
  
  <p>This is Selection Code
  </p>
  
  <pre><code>public List&lt;Category&gt; getAllCategorys() {
      List&lt;Category&gt; CategoryList = new ArrayList&lt;Category&gt;();
      // Select All Query
      String selectQuery = "SELECT  * FROM " + TABLE_CategoryS;
  
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor cursor = db.rawQuery(selectQuery, null);
  
      // looping through all rows and adding to list
      if (cursor.moveToNext()) {
          do {
              Category Category = new Category();
              Category.setID(Integer.parseInt(cursor.getString(0)));
              Category.setimg(Integer.parseInt(cursor.getString(1)));
              Category.setName(cursor.getString(2));
              Category.setSelected(cursor.getString(3));
              CategoryList.add(Category);
          } while (cursor.moveToNext());
      }
  
      // return Category list
      return CategoryList;
  }
  </code></pre>
  
  <p>this is Values
  </p>
  
  <pre><code>db.addCategory(new Category(R.drawable.angle, "Angle", "true"));
  db.addCategory(new Category(R.drawable.angle, "Area", "true"));
  db.addCategory(new Category(R.drawable.angle,"Currency", "true"));
  db.addCategory(new Category(R.drawable.angle,"Current", "true"));
  db.addCategory(new Category(R.drawable.angle,"Density", "true"));
  db.addCategory(new Category(R.drawable.angle,"Length", "true"));
  </code></pre>
  
  <p>This is Logcat error:
  </p>
  
  <pre><code>at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
      Caused by: java.lang.NumberFormatException: Invalid int: "Angle"
  at java.lang.Integer.invalidInt(Integer.java:138)
  at java.lang.Integer.parse(Integer.java:410)
  </code></pre>
  
  <p>its can't take int value . its move up to "Angle" value</p>
  
  <p>this is my create table query 
  </p>
  
  <pre><code>public void onCreate(SQLiteDatabase db) {
      String CREATE_CategoryS_TABLE = "CREATE TABLE " + TABLE_CategoryS + "("
          + KEY_ID + " INTEGER PRIMARY KEY," + KEY_IMG + "INTEGER," +
          KEY_NAME + " TEXT," + KEY_SELECTION + " TEXT"  + ")";
      db.execSQL(CREATE_CategoryS_TABLE);
  }
  </code></pre>
  
  <p>This is my Category Class:
  </p>
  
  <pre><code>public class Category 
  {
      int id;
      int img;
      String name = null;
      String selected = "true";
      public Category()
      {
  
      }
  
      public Category(int img, String name, String selected) {
  
          this.name = name;
          this.selected = selected;
          this.img = img;
      }
      public Category(int id,int img, String name, String selected) {
  
          this.id = id;
          this.name = name;
          this.selected = selected;
          this.img = img;
      }
  
      public int getID() { return id; }
  
      public void setID(int id) {
          this.id = id;
      }
  
      public int getimg() { return img; }
  
      public void setimg(int img) {
          this.img = img;
      }
  
      public String getName() { return name; }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String isSelected() {
          return selected;
      }
  
      public void setSelected(String selected) {
          this.selected = selected;
      }
  }
  </code></pre>