2011-01-20 6 views
0

私はエミュレータにデータベースをプッシュしようとしています。SQLiteOpenHelperが既存のデータベースを再作成するのはなぜですか?

CREATE TABLE android_metadata (locale TEXT); 
insert into android_metadata values('en_US'); 

CREATE TABLE notes (_id integer primary key autoincrement, 
        key text, 
        content text not null, 
        modifydate text, 
        createdate text, 
        syncnum integer, 
        version integer, 
        minversion integer, 
        sharekey text, 
        publishkey text, 
        deleted integer not null default 0, 
        pinned integer not null default 0, 
        unread integer not null default 0); 
CREATE TABLE tags (_id integer primary key autoincrement, 
        name text not null, 
        pos integer not null, 
        noteid integer not null, 
        foreign key(noteid) references notes (_id)); 

しかし、アプリは、それがすでに存在しているにもかかわらず、データベースを再作成しようとすると、いくつかの理由のため:私はそれは私のSQLiteOpenHelperサブクラスによって作成されたデータベースと同じに見えます、私のデスクトップコンピュータ上のスクリプトを使用してデータベースを作成しました。データベースにすでに存在するテーブルを作成しようとすると失敗します。なぜここに誰かがなぜ知っている?

+0

'android_metadata'行を取り除き、それが役立つかどうか確認してください。それはあなたのテーブルではないので、あなたは一人でそれを残すべきです。 – CommonsWare

答えて

0

OK。私のコードで期待されるのと同じバージョンにデータベースのバージョンを設定する必要があることが判明しました。これは私のsqliteスクリプトで行われます。

PRAGMA user_version = 1; 
関連する問題