0

我想将数据库 A 中的表中的一些列复制到数据库 B 中的表中。我使用以下代码,但它会打印错误消息“OldDB.ACC 表不存在”。我应该如何纠正它?谢谢!

顺便说一下,我把数据库 B (OldDB) 放到 DDMS/data/data/project name/databases

谢谢!!

public class DB {


private static final String TAG = "NotesDbAdapter";
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDb;

private static final String DATABASE_CREATE_ACC = "create table ACC "
        + "(_id integer primary key autoincrement, "
        + "Phone text, Name text, " + "MemID text, Smscode text, "
        + "RegDate text, Device text);";

private static final String DATABASE_NAME = "Db";

private static final String DATABASE_TABLE_ACC = "ACC";

private static final int DATABASE_VERSION = 1;

private final Context mCtx;

private static class DatabaseHelper extends SQLiteOpenHelper {

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

    // create the database if there is no database
    // database stored inside the application
    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL(DATABASE_CREATE_ACC);

        String str = "INSERT INTO " + DATABASE_TABLE_ACC + " (Phone) SELECT Phone FROM OldDB.ACC";
        db.execSQL(str);

    }
4

0 回答 0