mardi 12 janvier 2016

Copying data from one table to another in android

Am trying to copy all the values from table 1(ITEM_DETAIL_TABLE) to table 2 (ITEM_REFRESH_TABLE ). Below in my method. But while compiling am getting Syntax error. I don't know what is the problem.

public void ResetDbValues(){
                SQLiteDatabase db = MmpDBHelper.this.getWritableDatabase();
                 String sql1 = "INSERT INTO" + ITEM_REFRESH_TABLE + "SELECT * FROM " + ITEM_DETAIL_TABLE;
                 try {
                      Log.i("sql1=", sql1);

                      db.execSQL(sql1);


                    } catch (Exception exe) {
                        exe.printStackTrace();
                        db.endTransaction();
                        Log.e("Insertion failed",
                                "Transaction failure when inserting itemdet data.");
                        this.closeDatabase();
                        Log.i("DB closed", "Database closed successfully.");
                        errCode = "Err-DB-06";
                        LogFileCreator.appendLog(errCode + " : " + exe.getMessage());
                    }

}

Aucun commentaire:

Enregistrer un commentaire