-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
android.database.sqlite.SQLiteException - file is not a database (code 26) #32
Comments
Hello @UKMIITB In this case something is causing the key mismatch. There is not enough information to determine what, but that error is thrown when the incorrect key is used. You should check all the various edge cases, e.g. the implementations for your secured preferences, and any ways that a database could be used without a corresponding preference (e.g. restore from backup, transfer onto a different device, generation of passphrase, etc). |
I was able to reproduce this issue with a 100% "success" rate, @sjlombardo. I'm testing this on a Pixel 7A with Android API 34 and version Essentially, in my case, the application always crashes if I try to insert an item and I have never performed any SELECT statement before. |
Hi @GrenderG, Can you post a public repo with a small test reproduction of the behavior you are seeing? We would be happy to investigate this further with a test case. Thanks! |
Hello, I can try to do that this week. However, it should be very simple to test; basically you just need to open the app for the first time, then try to insert data without having performed any SELECT query before. For the record, this is how I get the instance: public static synchronized DummyDatabase getInstance(Context context) {
System.loadLibrary("sqlcipher");
return Room.databaseBuilder(context.getApplicationContext(),
DummyDatabase.class, Constants.DATABASE_NAME)
.fallbackToDestructiveMigration()
.setAutoCloseTimeout(60, TimeUnit.SECONDS)
.openHelperFactory(new SupportOpenHelperFactory(
Constants.DB_DEFAULT_PASSWORD.getBytes(StandardCharsets.UTF_8)))
.build();
} To note:
|
@GrenderG - in the scenario you are describing, does does the database already exist, or is the application creating a new database? |
The application is creating a new database. |
Hello, I tried it and the crash wasn't happening (my app is made with Java, not Kotlin, probably not relevant though). However, I found a way to avoid the crash in my scenario: if I use |
Hi @GrenderG, Thanks for the update, glad to hear you were able to resolve the issue. |
I am experiencing the same issue. In my case, it appears to be an already existing database. We're storing the key in encrypted shared preferences for several different databases, and setting the key if it doesn't exist. I wonder if we're hitting an odd race condition in shared prefs, or if it's something internal to sqlcipher? |
Hey @mandrachek a thread is going on for your use case |
I am getting this crash in production.
Its not happening for all users & not reproducible. But in production this is happening.
This is the code for initialisation.
So here once passphrase is generated same passphrase is getting used. And we donot clear that passphrase from shared preference, so the case of trying to open from another passphrase would not happen.
The text was updated successfully, but these errors were encountered: