title: Error while inserting record in table of sqlite
body: <p>I am getting data from the other table using webservices.I am tracing each value of the table so i am sure that i am getting values but i am unable to insert them into my new table.I am not able to get where i went would any one help me out..</p>
  
  <p>The code i am using for this is</p>
  
  <pre><code>         private void insertData(String bbookId,String bdesc, byte[] image1,byte[] image2 ,String bid,String bname) {
              Log.i("id",bid);
              Log.i("BookId",bbookId);
              Log.i("name",bname);
              System.err.println("url1"+image1);
              System.err.println("url2"+image2);
              System.err.println("desc"+bdesc);
              Log.e("testing","LOOK @ 1214353469TRJB UJIOY ");
               SQLiteDatabase db = placeData.getWritableDatabase();
               Log.i("Bookid",bbookId);
               ContentValues values;
               values = new ContentValues();
               values.put("bbookid",bbookId);
               values.put("desc",bdesc);
               values.put("url1",image1);
               values.put("url2",image2);
  
               values.put("bid",bid);
               values.put("name", bname);
               Log.i("inserting","______________");
                db.insert("pagess", null, values); 
          } 
  </code></pre>
  
  <p>I am getting all the log values successfully and the log tag "inserting" <strong>_</strong> is also being displayed</p>
  
  <p>My database class is ::::::::</p>
  
  <pre><code>   public class PlaceData extends SQLiteOpenHelper {
  private static final String DATABASE_NAME = "page.db";
  private static final String DATABASE_TABLE = "pagess";
  private static final int DATABASE_VERSION = 1;
  private static final String KEY_ID="bid";
  private static final String KEY_BBOOKID="bbookid";
  private static final String KEY_NAME="name";
  private static final String KEY_URL1="url1";
  private static final String KEY_URL2="url2";
  private static final String KEY_DESC="desc";
   private SQLiteDatabase sqLiteDatabase;
  private Context context;
  public PlaceData(Context context) {
      super(context, DATABASE_NAME, null, DATABASE_VERSION);
      this.context = context;
  }
  @Override
  public void onCreate(SQLiteDatabase db) {
      Log.i("table","table");
      Log.i("bookid in table is ",KEY_BBOOKID);
      db.execSQL("CREATE TABLE " + DATABASE_TABLE+"("+KEY_BBOOKID+" varchar(15),"+KEY_DESC+" text(1500),"+KEY_URL1+" BLOB,"+KEY_URL2+" BLOB,"+KEY_ID+" INTEGER PRIMARY KEY AUTOINCREMENT ,"+KEY_NAME+" varchar(150))");   
  }   
  public void createDataBase() throws IOException{
       boolean dbExist = checkDataBase(DATABASE_NAME);
       if(dbExist){
      Log.i("g","ds");         
       }else{
        CopyFiles();
       }
      }
      private void CopyFiles()
      {
       try
          {
          InputStream is = context.getAssets().open(DATABASE_NAME);
           File outfile = new File("data/data/com.books.bcukbook/databases/",DATABASE_NAME);
           outfile.getParentFile().mkdirs();
           outfile.createNewFile();
  
          if (is == null)
            throw new RuntimeException("stream is null");
          else
          {
               FileOutputStream out = new FileOutputStream(outfile);      
           byte buf[] = new byte[128];
               do {
                int numread = is.read(buf);
                   if (numread &lt;= 0)
                       break;
                out.write(buf, 0, numread);
                 } while (true);
  
               is.close();
               out.close();
          }
          }
          catch (IOException e)
          {
             throw new RuntimeException(e);
          }
  
      }    
      public long insert(String bbookid, String desc,String url1,String url2,String bid,String name){
  
            ContentValues contentValues = new ContentValues();      
            contentValues.put(KEY_BBOOKID,bbookid);
            contentValues.put(KEY_DESC,desc);
            contentValues.put(KEY_URL1,url1);
            contentValues.put(KEY_URL2,url2);
            contentValues.put(KEY_ID,bid);
            contentValues.put(KEY_NAME,name);
            return sqLiteDatabase.insert(DATABASE_TABLE, null, contentValues);
           }
      public Cursor selectQuery(String query) throws SQLException
      {
       String myPath = "data/data/com.books.bcukbook/databases/" + DATABASE_NAME;
       CursorFactory bcuk_pages = null;
       SQLiteDatabase myData = SQLiteDatabase.openDatabase(myPath, bcuk_pages, SQLiteDatabase.OPEN_READWRITE);
       Cursor mCursor =myData.rawQuery(query, null);
       mCursor.moveToFirst();    
          myData.close();
          return mCursor;
      }
  private void versionUpdation(SQLiteDatabase db) {
  
  }
  public boolean checkDataBase(String db) {
  
      SQLiteDatabase checkDB = null;
       File dbFile = new File( "data/data/com.books.bcukbook/databases/" +  DATABASE_NAME);  
         return dbFile.exists();
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      if (oldVersion &gt;= newVersion)
          return;
      if (oldVersion == 1) {
          Log.d("New Version", "Datasadsggfdh can be upgraded");
      }
      Log.d("Sample Data", "onUpgrade : " + newVersion);
  }
       @Override
       public synchronized void close() {
             super.close();
       }
  
      }
  </code></pre>
  
  <p>My Log shows as</p>
  
  <pre><code>  12-10 14:13:41.285: I/inserting(30596): ______________
    12-10 14:13:41.295: E/SQLiteDatabase(30596): Error inserting bbookid=1 desc=&lt;p&gt;Providing in-depth coverage of how to build mobile applications using the next major release of the Android SDK, this invaluable resource takes a hands-on approach to discussing Android with a series of projects, each of which introduces a new feature and highlights techniques and best practices to get the most out of Android.&lt;/p&gt; url1=[B@42725768 bid=2 url2=[B@42636730 name=Hello World page1
    12-10 14:13:41.295: E/SQLiteDatabase(30596): android.database.sqlite.SQLiteConstraintException: PRIMARY KEY must be unique (code 19)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:775)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at com.books.bcukbook.DetailsActivity$LoadAllProducts.insertData(DetailsActivity.java:688)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at com.books.bcukbook.DetailsActivity$LoadAllProducts.callInsertion(DetailsActivity.java:663)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at com.books.bcukbook.DetailsActivity$LoadAllProducts.doInBackground(DetailsActivity.java:616)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at com.books.bcukbook.DetailsActivity$LoadAllProducts.doInBackground(DetailsActivity.java:1)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
    12-10 14:13:41.295: E/SQLiteDatabase(30596):  at java.lang.Thread.run(Thread.java:856)
  </code></pre>