In Encrypted database, How to check whether the db connection is succesful or not ? #1502
Answered
by
simolus3
rajagopalx
asked this question in
Q&A
-
Hi, I am using the encrypted database. If I input the wrong passphrase how to catch the exception Currently, I am getting exception if I am inserting records into the db. But, Is there any other way to check whether the database connection is success or not. P.S: I am new to flutter development. My Code
|
Beta Was this translation helpful? Give feedback.
Answered by
simolus3
Oct 20, 2021
Replies: 1 comment 1 reply
-
You could add a simple statement accessing the database in the setup: (rawDb) {
rawDb.execute("PRAGMA key = 'wrongpassword';");
try {
rawDb.execute('PRAGMA user_version;');
} on SqliteException catch (e) {
if (e.resultCode == 26) {
// not a database, the password is probably wrong
}
}
}, |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rajagopalx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could add a simple statement accessing the database in the
setup
callback, like this: