| 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 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| interface | RepairKit.Callback | Listener for repairing progress report. | |||||||||
| 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. |
|||||||||
| int | RESULT_CANCELED | Result code that indicates operation has been cancelled. | |||||||||
| int | RESULT_FAILED | Result code that indicates operation failure. | |||||||||
| int | RESULT_IGNORE | ||||||||||
| int | RESULT_OK | Result code that indicates successful operation. | |||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
RepairKit(String path, byte[] key, SQLiteCipherSpec cipherSpec, RepairKit.MasterInfo master)
Open a corrupted database for repairing.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| RepairKit.Callback |
getCallback()
Returns the progress callback set previously.
| ||||||||||
| 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.
| ||||||||||
| void |
onCancel()
Called when
cancel() is invoked. | ||||||||||
| int |
output(SQLiteDatabase db, int flags, CancellationSignal cancellationSignal)
Parse corrupted database and output its content to
db. | ||||||||||
| int |
output(SQLiteDatabase db, int flags)
Parse corrupted database and output its content to
db. | ||||||||||
| void |
release()
Close corrupted database and release all resources.
| ||||||||||
| void |
setCallback(RepairKit.Callback callback)
Set the progress callback to be called during
output(SQLiteDatabase, int). | ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.tencent.wcdb.support.CancellationSignal.OnCancelListener
| |||||||||||
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.
Result code that indicates operation has been cancelled.
Result code that indicates operation failure.
Result code that indicates successful operation.
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. |
Returns the progress callback set previously.
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 |
| cancellationSignal | A signal to cancel the operation in progress, or null if none |
RESULT_OK, RESULT_CANCELED
or RESULT_FAILED.
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 |
RESULT_OK, RESULT_CANCELED
or RESULT_FAILED.
Close corrupted database and release all resources. Do not call any methods after this method is called.
Set the progress callback to be called during output(SQLiteDatabase, int).
| callback | the callback object to be set |
|---|