Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
5c751488
Commit
5c751488
authored
Nov 30, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for downgrading the database for whatever reason
And it simply kills all the data.
parent
ae833210
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
83 deletions
+86
-83
mobile/src/main/scala/com/github/shadowsocks/database/DBHelper.scala
...main/scala/com/github/shadowsocks/database/DBHelper.scala
+86
-83
No files found.
mobile/src/main/scala/com/github/shadowsocks/database/DBHelper.scala
View file @
5c751488
...
...
@@ -27,8 +27,8 @@ import android.content.pm.ApplicationInfo
import
android.database.sqlite.SQLiteDatabase
import
android.preference.PreferenceManager
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.preference.OrmLitePreferenceDataStore
import
com.github.shadowsocks.utils.Key
import
com.j256.ormlite.android.AndroidDatabaseConnection
import
com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
import
com.j256.ormlite.dao.Dao
import
com.j256.ormlite.support.ConnectionSource
...
...
@@ -68,9 +68,7 @@ class DBHelper(val context: Context)
onCreate
(
database
,
connectionSource
)
}
def
onUpgrade
(
database
:
SQLiteDatabase
,
connectionSource
:
ConnectionSource
,
oldVersion
:
Int
,
newVersion
:
Int
)
{
if
(
oldVersion
!=
newVersion
)
{
def
onUpgrade
(
database
:
SQLiteDatabase
,
connectionSource
:
ConnectionSource
,
oldVersion
:
Int
,
newVersion
:
Int
)
{
if
(
oldVersion
<
7
)
{
recreate
(
database
,
connectionSource
)
return
...
...
@@ -156,8 +154,13 @@ class DBHelper(val context: Context)
case
ex
:
Exception
=>
app
.
track
(
ex
)
recreate
(
database
,
connectionSource
)
return
}
}
override
def
onDowngrade
(
db
:
SQLiteDatabase
,
oldVersion
:
Int
,
newVersion
:
Int
)
{
val
connection
=
new
AndroidDatabaseConnection
(
db
,
true
)
connectionSource
.
saveSpecialConnection
(
connection
)
recreate
(
db
,
connectionSource
)
connectionSource
.
clearSpecialConnection
(
connection
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment