objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

io.objectbox.exception.FileCorruptException: Could not open database environment; please check options and file system (corrupted) (error code -30796)

Open unengchen opened this issue 4 years ago • 1 comments

Describe the bug In android Application to build boxStore to occurred th problem.

private var boxStore: BoxStore? = null
    fun initBox(context: Context) {
        boxStore = MyObjectBox.builder()
            .androidContext(context.applicationContext).build()

        if (BuildConfig.DEBUG) {
            AndroidObjectBrowser(boxStore).start(context)
        }
    }

the error info : Could not open database environment; please check options and file system (corrupted) (error code -30796)

Basic info (please complete the following information):

  • ObjectBox version 2.9.1
  • Reproducibility:
  • Device: rk3288
  • OS: Android 8.1

unengchen avatar Oct 27 '21 07:10 unengchen

A similar issue affecting Android 8.1 devices has been reported at #926. This error means the database file has been corrupted.

There are various options to handle this. It is possible to

  • try to use the previous version of the database, see https://github.com/objectbox/objectbox-examples/blob/aeff8803c87d82af330b4960e919c8f6b98ecdfa/android-app/src/main/java/io/objectbox/example/ObjectBox.java#L17-L28 for an example,
  • detect the error and notify the user https://github.com/objectbox/objectbox-examples/blob/aeff8803c87d82af330b4960e919c8f6b98ecdfa/android-app-kotlin/src/main/java/io/objectbox/example/kotlin/ObjectBox.kt#L37-L50
  • detect the error, delete the database file and build a new BoxStore.

greenrobot-team avatar Nov 02 '21 09:11 greenrobot-team

Closing this issue due to inactivity. :zzz: Feel free to comment with more details or submit a new issue.

greenrobot-team avatar Jul 10 '23 11:07 greenrobot-team