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 8949239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:10:57+00:00 2026-06-15T13:10:57+00:00

I just want to copy the table from table1 to table2 in the same

  • 0

I just want to copy the table from table1 to table2 in the same database. I surfed around and i got some errors. Here is my source code :

I followed this link : Copy table

public class SelectedCandidatesDB {

public static final String KEY_NAME1 = "name1";
public static final String KEY_NAME2 = "name2";
public static final String KEY_NAME3 = "name3";
public static final String KEY_NAME4 = "name4";
public static final String KEY_NAME5 = "name5";
public static final String KEY_ID = "_id";
private final Context mCtx;
private static final String TAG = "CountriesDbAdapter";
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDb;

// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "selectedcandidates.db";
// Contacts table name
private static final String TABLE_SELECTED_CAND = "selectedcandids";
private static final String TABLE_RECOUNT1 = "rec1";
private static final String TABLE_RECOUNT2 = "recountedsecond";
private static final String TABLE_RECOUNT3 = "recountedthird";

private static final String CREATE_SELECTED_CAND_TABLE = " CREATE TABLE if not exists "
        + TABLE_SELECTED_CAND
        + "("
        + KEY_ID
        + " integer PRIMARY KEY autoincrement,"
        + KEY_NAME1
        + " TEXT,"
        + KEY_NAME2
        + " TEXT,"
        + KEY_NAME3
        + " TEXT,"
        + KEY_NAME4
        + " TEXT," + KEY_NAME5 + " TEXT" + ")";

private static final String CREATE_SELECTED_CAND_RECOUNT1 = " CREATE TABLE if not exists "
        + TABLE_RECOUNT1
        + "("
        + KEY_ID
        + " integer PRIMARY KEY autoincrement,"
        + KEY_NAME1
        + " TEXT,"
        + KEY_NAME2
        + " TEXT,"
        + KEY_NAME3
        + " TEXT,"
        + KEY_NAME4
        + " TEXT," + KEY_NAME5 + " TEXT" + ")";
private static final String CREATE_SELECTED_CAND_RECOUNT2 = " CREATE TABLE if not exists "
        + TABLE_RECOUNT2
        + "("
        + KEY_ID
        + " integer PRIMARY KEY autoincrement,"
        + KEY_NAME1
        + " TEXT,"
        + KEY_NAME2
        + " TEXT,"
        + KEY_NAME3
        + " TEXT,"
        + KEY_NAME4
        + " TEXT," + KEY_NAME5 + " TEXT" + ")";
private static final String CREATE_SELECTED_CAND_RECOUNT3 = " CREATE TABLE if not exists "
        + TABLE_RECOUNT3
        + "("
        + KEY_ID
        + " integer PRIMARY KEY autoincrement,"
        + KEY_NAME1
        + " TEXT,"
        + KEY_NAME2
        + " TEXT,"
        + KEY_NAME3
        + " TEXT,"
        + KEY_NAME4
        + " TEXT," + KEY_NAME5 + " TEXT" + ")";

private static class DatabaseHelper extends SQLiteOpenHelper {

    DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL(CREATE_SELECTED_CAND_RECOUNT1);
        db.execSQL(CREATE_SELECTED_CAND_TABLE);

        Log.d("Selected Candidate DB ",
                "The Table recount 1 has been created :");
        db.execSQL(CREATE_SELECTED_CAND_RECOUNT2);
        db.execSQL(CREATE_SELECTED_CAND_RECOUNT3);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS " + CREATE_SELECTED_CAND_RECOUNT1);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_SELECTED_CAND);

        db.execSQL("DROP TABLE IF EXISTS " + CREATE_SELECTED_CAND_RECOUNT2);
        db.execSQL("DROP TABLE IF EXISTS " + CREATE_SELECTED_CAND_RECOUNT3);
        onCreate(db);
    }
}

public SelectedCandidatesDB(Context ctx) {
    this.mCtx = ctx;
}

public SelectedCandidatesDB open() throws SQLException {
    mDbHelper = new DatabaseHelper(mCtx);
    mDb = mDbHelper.getWritableDatabase();
    return this;
}

public void close() {
    if (mDbHelper != null) {
        mDbHelper.close();
    }
}


  // ************** 


    public void copyToRecount1() {

    mDb.execSQL(" INSERT INTO " + TABLE_RECOUNT1 + " SELECT * FROM "
            + TABLE_SELECTED_CAND);
}

and the logs are :

   I/SqliteDatabaseCpp(12637): sqlite returned: error code = 1, msg = no
   such table: rec1, db=xxx   D/AndroidRuntime(12637): Shutting down VM 
   threadid=1: thread exiting with uncaught exception (group=0x40c501f8)
   E/AndroidRuntime(12637): 

   FATAL EXCEPTION: main 
   E/AndroidRuntime(12637): android.database.sqlite.SQLiteException: ***no such table: rec1: , while compiling: INSERT INTO rec1 SELECT * FROM selectedcandids***   
   E/AndroidRuntime(12637):     at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)   
   E/AndroidRuntime(12637):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
   E/AndroidRuntime(12637):     at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143)
   E/AndroidRuntime(12637):     at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
   E/AndroidRuntime(12637):     at android.database.sqlite.SQLiteStatement.acquireAndLock(SQLiteStatement.java:260)
   E/AndroidRuntime(12637):     at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:84)
   E/AndroidRuntime(12637):     at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:2028)
   E/AndroidRuntime(12637):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1968)
   E/AndroidRuntime(12637):     at com.dana.db.SelectedCandidatesDB.copyToRecount1(SelectedCandidatesDB.java:264)
   E/AndroidRuntime(12637):     at com.dana.votecount.VoteRecount$2$1.onClick(VoteRecount.java:91)
   E/AndroidRuntime(12637):     at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
  • 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-15T13:10:58+00:00Added an answer on June 15, 2026 at 1:10 pm

    Error says you don’t have table ‘rec1’. Maybe you added this table later after creating the database. Uninstall your app and run again.It will create db and all the table again.

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

Sidebar

Related Questions

I want to copy data from two columns in a 'table1' to another table
I want to copy data from one database which has table named domains to
I just want to add some extra text on top of input posted from
Sometimes if I want to quickly copy records from one table to another (that
quite the same question as here : Copy data from one existing row to
I'm just copy & pasting some of the introductory text from one of my
Just want to know how to read an attribute of a parent node from
How do I copy a selection of rows from a mySql table and insert
I Want to copy all the data of a table (with a certain id
I've rails 3 app which displays records from a DB into table. I want

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.