diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2010-10-12 01:45:34 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-10-12 01:45:34 -0700 |
commit | 1e6a25aadb334ad41aa0cab821735b9765d791b4 (patch) | |
tree | 5972fc4118b32b3f9464c88aaed0e0bc98a748d3 /src/com/android/browser/BrowserProvider.java | |
parent | 67832037dbba03f34873878d3f8080ded2ec1017 (diff) | |
parent | 6c767e7dc1a6fd9adc5ea8930ad1432a48b74b95 (diff) | |
download | packages_apps_browser-1e6a25aadb334ad41aa0cab821735b9765d791b4.zip packages_apps_browser-1e6a25aadb334ad41aa0cab821735b9765d791b4.tar.gz packages_apps_browser-1e6a25aadb334ad41aa0cab821735b9765d791b4.tar.bz2 |
am 6c767e7d: am 6d25c81e: Merge "Protection against bookmarks with url=null in the database"
Merge commit '6c767e7dc1a6fd9adc5ea8930ad1432a48b74b95'
* commit '6c767e7dc1a6fd9adc5ea8930ad1432a48b74b95':
Protection against bookmarks with url=null in the database
Diffstat (limited to 'src/com/android/browser/BrowserProvider.java')
-rw-r--r-- | src/com/android/browser/BrowserProvider.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java index f371e24..cba16a0 100644 --- a/src/com/android/browser/BrowserProvider.java +++ b/src/com/android/browser/BrowserProvider.java @@ -162,7 +162,8 @@ public class BrowserProvider extends ContentProvider { // 20 -> 21 Added touch_icon // 21 -> 22 Remove "clientid" // 22 -> 23 Added user_entered - private static final int DATABASE_VERSION = 23; + // 23 -> 24 Url not allowed to be null anymore. + private static final int DATABASE_VERSION = 24; // Regular expression which matches http://, followed by some stuff, followed by // optionally a trailing slash, all matched as separate groups. @@ -245,7 +246,7 @@ public class BrowserProvider extends ContentProvider { db.execSQL("CREATE TABLE bookmarks (" + "_id INTEGER PRIMARY KEY," + "title TEXT," + - "url TEXT," + + "url TEXT NOT NULL," + "visits INTEGER," + "date LONG," + "created LONG," + @@ -297,6 +298,27 @@ public class BrowserProvider extends ContentProvider { } if (oldVersion < 23) { db.execSQL("ALTER TABLE bookmarks ADD COLUMN user_entered INTEGER;"); + } + if (oldVersion < 24) { + /* SQLite does not support ALTER COLUMN, hence the lengthy code. */ + db.execSQL("DELETE FROM bookmarks WHERE url IS NULL;"); + db.execSQL("ALTER TABLE bookmarks RENAME TO bookmarks_temp;"); + db.execSQL("CREATE TABLE bookmarks (" + + "_id INTEGER PRIMARY KEY," + + "title TEXT," + + "url TEXT NOT NULL," + + "visits INTEGER," + + "date LONG," + + "created LONG," + + "description TEXT," + + "bookmark INTEGER," + + "favicon BLOB DEFAULT NULL," + + "thumbnail BLOB DEFAULT NULL," + + "touch_icon BLOB DEFAULT NULL," + + "user_entered INTEGER" + + ");"); + db.execSQL("INSERT INTO bookmarks SELECT * FROM bookmarks_temp;"); + db.execSQL("DROP TABLE bookmarks_temp;"); } else { db.execSQL("DROP TABLE IF EXISTS bookmarks"); db.execSQL("DROP TABLE IF EXISTS searches"); |