Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8967435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:14:32+00:00 2026-06-15T17:14:32+00:00

I am getting data from the other table using webservices.I am tracing each value

  • 0

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..

The code i am using for this is

         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); 
        } 

I am getting all the log values successfully and the log tag “inserting” _ is also being displayed

My database class is ::::::::

   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 <= 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 >= 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();
     }

    }

My Log shows as

  12-10 14:13:41.285: I/inserting(30596): ______________
  12-10 14:13:41.295: E/SQLiteDatabase(30596): Error inserting bbookid=1 desc=<p>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.</p> 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)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:14:34+00:00Added an answer on June 15, 2026 at 5:14 pm

    Remove

    values.put("bid",bid); From insert Statement values.

    As bid is Auto Increment Primary Key.

    And try again..

    Update:

    From your PlaceData Database class.

    KEY_ID+" INTEGER PRIMARY KEY AUTOINCREMENT 
    

    And private static final String KEY_ID="bid";

    So you don’t have to insert bid Primary Key. Your Sqlite Table automatically generates (increment) it. For every New inserted Record.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting data from iphone using php but when i insert post data
here i,m trying to enter data into table playlist using information extracted from other
I need to automate a process that involves getting data from a series of
What are the differences between using SqlDataAdapter vs SqlDataReader for getting data from a
I have a custom list view that is getting data from server and changing
I need to extract data from a DB2 table, run some processing on each
I'm using Oracle 9.2 with Weblogic 8 server. I'm getting the Data from a
I have created a repository that is returning data from my database using Entity
Using Oracle 11 I'm wanting to pull data from a table, and add a
Im getting data from a server by executing this code: - (void) sendGeneral:(NSString *)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.