2

I am using a singleton object to perform database operations. I made bulk insertion demo and made insertions by both SQLCipher library with empty encryption key("") & DataBaseHelper.

I observed that DataBaseHelper is taking less time than SQLCipher for bulk insertions.

Can you please elaborate what extra things is the SQLCipher doing at the time of db operations. Is there any way to overcome this issue? Note: I have 4 databases, 2 out of 4 are needed for encryption and other 2 without encryption. But I am using common access helper class for both these types of Databases. Where encryption is not required, I pass ("") empty string as an argument to open database.

After examining both SQLCipher and android default DatabaseHelper, I came up with a conclusion that, SQLCipher takes sightly more time than DataBaseHelper for db operations.

Kindly, suggest me with solutions.

Rohan Patel
  • 1,758
  • 2
  • 21
  • 38
  • Encryption adds overhead. That is intrinsic to all forms of encryption. So long as the bulk insertion time is reasonable, whether it is slightly slower with SQLCipher for Android or not should not matter. Focus on making bulk insertions faster in general, such as wrapping them in a single transaction, using prepared statements, etc. – CommonsWare Sep 26 '14 at 12:18
  • Forget about bulk insertion, leggings also happened in single record insertion. SQLCipher takes more time compare to DataBaseHelper. – Rohan Patel Sep 26 '14 at 12:55
  • So? Again, encryption adds overhead. That is intrinsic to all forms of encryption. Hence, it is pointless to worry about whether encrypted database access will be slower than unencrypted database access. What matters is whether the overhead is such that it will cause problems for the user. So far, I have not seen that as being an issue, though I certainly can't rule it out for some rather complex database structures or access patterns. – CommonsWare Sep 26 '14 at 13:02
  • When I opening database each time for a query at that time it makes different. If i open database on app startup and close at time of app shutdown, its works fine without legging. UnEncrypted database also extends SQLCipher's SQLiteOpenHelper. Do i need to use database.sqlite.SQLiteOpenHelper for unEncrypted database? – Rohan Patel Sep 29 '14 at 06:22
  • "If i open database on app startup and close at time of app shutdown, its works fine without legging" -- that is the normal pattern of using SQLite, let alone SQLCipher. "Do i need to use database.sqlite.SQLiteOpenHelper for unEncrypted database?" -- the SQLCipher classes can work with an unencrypted database, by passing in an empty password (`""`). – CommonsWare Sep 29 '14 at 10:59

0 Answers0