java.lang.Object | |
↳ | com.tencent.wcdb.repair.RepairKit |
Database repair toolkit to parse a corrupted database file and write its content to another (newly created) database.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class | RepairKit.MasterInfo | Class represent master info backed up from a SQLiteDatabase , which
can be used in recovery on database file with corrupted header. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | FLAG_ALL_TABLES | Flag indicates all tables and indices should be written to the destination database, regardless to how table filters are set. | |||||||||
int | FLAG_NO_CREATE_TABLES | Flag indicates no CREATE TABLE or CREATE INDEX statement
should be executed on the destination database. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
RepairKit(String path, byte[] key, SQLiteCipherSpec cipherSpec, RepairKit.MasterInfo master)
Open a corrupted database for repairing.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean |
isDataCorrupted()
Retrieve whether data is corrupted.
| ||||||||||
boolean |
isHeaderCorrupted()
Retrieve whether database header is corrupted.
| ||||||||||
boolean |
isSaltCorrupted()
Retrieve whether KDF salt is corrupted.
| ||||||||||
static String |
lastError()
Retrieve the last error message.
| ||||||||||
boolean |
output(SQLiteDatabase db, int flags)
Parse corrupted database and output its content to
db . | ||||||||||
void |
release()
Close corrupted database and release all resources.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Flag indicates all tables and indices should be written to the destination database, regardless to how table filters are set.
Flag indicates no CREATE TABLE
or CREATE INDEX
statement
should be executed on the destination database.
Open a corrupted database for repairing.
Database is successfully opened and ready to be parsed when the constructor returns
without throwing exceptions. The caller should catch SQLiteException
in case of
failure due to file opening error, wrong password, or unrecoverable corruption.
Backup master info can be provided for better chance of recovery.
Backup master info can be saved before the database is corrupted by calling
save(SQLiteDatabase, String, byte[])
. To use backup master info
on recovery, call load(String, byte[], String[])
on saved info
and pass it as master
argument.
Table filters can be applied to recover only selected tables. Calling make(String[])
or load(String, byte[], String[])
to generate table filters.
path | path to the corrupted database to be repaired |
---|---|
key | password to the encrypted database, or null for plain-text database |
cipherSpec | cipher description, or null for default settings |
master | backup master info and/or table filters |
SQLiteException | when corrupted database cannot be opened. |
---|---|
IllegalArgumentException | when path is null. |
Retrieve whether data is corrupted.
true
if corrupted
Retrieve whether database header is corrupted.
true
if corrupted
Retrieve whether KDF salt is corrupted.
true
if corrupted
Retrieve the last error message.
Parse corrupted database and output its content to db
.
This method does not return until repairing is finished. Don't call it in the main thread or it will cause ANR.
db | destination database to be written |
---|---|
flags | flags affects repair behavior |
true
if at least one row is successfully repaired
Close corrupted database and release all resources. Do not call any methods after this method is called.