Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Migration_9_10.java « migration « persistence « notes « owncloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9aec3c9b750c13e0ec002f52349c20715aecd387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package it.niedermann.owncloud.notes.persistence.migration;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import it.niedermann.owncloud.notes.util.NoteUtil;

public class Migration_9_10 {
    public Migration_9_10(SQLiteDatabase db, int oldVersion) {
        if (oldVersion < 10) {
            db.execSQL("ALTER TABLE NOTES ADD COLUMN EXCERPT INTEGER NOT NULL DEFAULT ''");
            Cursor cursor = db.query("NOTES", new String[]{"ID", "CONTENT"}, null, null, null, null, null, null);
            while (cursor.moveToNext()) {
                ContentValues values = new ContentValues();
                values.put("EXCERPT", NoteUtil.generateNoteExcerpt(cursor.getString(1)));
                db.update("NOTES", values, "ID" + " = ? ", new String[]{cursor.getString(0)});
            }
            cursor.close();
        }
    }
}