# SQLCipher for Android Refresh (Beta)

**URL:** <https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405>\
**Category:** SQLCipher\
**Created:** [May 11, 2022, 2:14pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405 "2022-05-11T14:14:28Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [May 11, 2022, 2:14pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/1 "2022-05-11T14:14:28Z")

</div>

We are happy to announce the beta availability of a new SQLCipher for Android client library. This new library provides major benefits including optimized support for concurrent database access, drastic performance improvements, API simplification, and codebase modernization. Please read more about this here:

> **[SQLCipher for Android Refresh](https://www.zetetic.net/blog/2022/05/11/sqlcipher-android-refresh/)**
>
> SQLCipher for Android Refresh

---

<div class="post-metadata">

**Author:** ![jmm09312](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/jmm09312/32/1802_2.png) [@jmm09312](https://discuss.zetetic.net/u/jmm09312)\
**Post date:** [May 23, 2022, 11:24am UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/2 "2022-05-23T11:24:33Z")

</div>

More information is needed on how to build this new library using OpenSSL 3.0 and the FIPS provider module. (ie build flags, config files, loading of the FIPS provider, calling validation tests, etc.).

---

<div class="post-metadata">

**Author:** ![Alain\_El\_Hakim](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/alain_el_hakim/32/1829_2.png) [@Alain\_El\_Hakim](https://discuss.zetetic.net/u/Alain_El_Hakim)\
**Post date:** [May 31, 2022, 11:40am UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/3 "2022-05-31T11:40:15Z")

</div>

Hi, any timelines for publishing SQLCypher for Android Refresh Community editions as stated in the linked announcement? Thanks.

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [May 31, 2022, 9:13pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/4 "2022-05-31T21:13:58Z")

</div>

Hi @Alain_El_Hakim

We don’t have a time frame yet, however, it will likely align with a public SQLCipher core release in the future. Please keep an eye on the Discuss site, we’ll create a post as soon as it is available.

---

<div class="post-metadata">

**Author:** ![Alain\_El\_Hakim](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/alain_el_hakim/32/1829_2.png) [@Alain\_El\_Hakim](https://discuss.zetetic.net/u/Alain_El_Hakim)\
**Post date:** [June 1, 2022, 8:51am UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/5 "2022-06-01T08:51:42Z")

</div>

Hi @developernotes , appreciate your prompt response. If I am correct, the Android Refresh library is already available in the commercial version (in Beta), where could I read more about the commercial licensing? Thanks.

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [June 1, 2022, 1:10pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/6 "2022-06-01T13:10:04Z")

</div>

Hi @Alain_El_Hakim

That is correct, Commercial licenses of SQLCipher for Android may be purchased [here](https://www.zetetic.net/sqlcipher/commercial-edition-ordering).

---

<div class="post-metadata">

**Author:** ![Alain\_El\_Hakim](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/alain_el_hakim/32/1829_2.png) [@Alain\_El\_Hakim](https://discuss.zetetic.net/u/Alain_El_Hakim)\
**Post date:** [June 2, 2022, 12:12pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/7 "2022-06-02T12:12:25Z")

</div>

Hi,  
That’s great, we are dealing with the following exception causing our app to crash (we are actually on the community release version), and it is giving us hard time to reproduce. Can you suggest a way how we can verify that new library resolves that issue. Or maybe if you could help to pinpoint the root cause.

Fatal Exception: java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds  
at net.sqlcipher.database.SQLiteCompiledSql.native\_finalize(SQLiteCompiledSql.java)  
at net.sqlcipher.database.SQLiteCompiledSql.releaseSqlStatement(SQLiteCompiledSql.java:103)  
at net.sqlcipher.database.SQLiteCompiledSql.finalize(SQLiteCompiledSql.java:141)  
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:209)  
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:192)  
at java.lang.Thread.run(Thread.java:818)

We really appreciate your help.

Thanks,  
A.

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [June 2, 2022, 1:30pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/8 "2022-06-02T13:30:28Z")

</div>

Hi @Alain_El_Hakim

What version of SQLCipher for Android are you using? We removed the [locking around the finalizer](https://github.com/sqlcipher/android-database-sqlcipher/commit/628568beff527518f1adab9a07f1b66711ffc3f0) last year. If you aren’t running the latest (currently 4.5.1), you might consider upgrading. Also, you can try calling `setLockingEnabled(false)` on your connection once opened.

---

<div class="post-metadata">

**Author:** ![pradeep07](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pradeep07](https://discuss.zetetic.net/u/pradeep07)\
**Post date:** [February 7, 2023, 6:18pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/9 "2023-02-07T18:18:39Z")

</div>

We getting the same exception

java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds  
at net.sqlcipher.database.SQLiteCompiledSql.native\_finalize(Native Method)  
at net.sqlcipher.database.SQLiteCompiledSql.releaseSqlStatement(SQLiteCompiledSql.java:103)  
at net.sqlcipher.database.SQLiteCompiledSql.finalize(SQLiteCompiledSql.java:141)  
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:202)  
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:185)  
at java.lang.Thread.run(Thread.java:818)

Note this looks like it has the fix you mentioned about removing the locking around finalizer, but it’s happening in the native\_finalize method. Using version 4.5.2

In this case we should call setLockingEnabled(false) ?

Thanks,

Pradeep

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [February 8, 2023, 4:00pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/10 "2023-02-08T16:00:56Z")

</div>

Hi @pradeep07,

Can you try setting `setLockingEnabled(false)` and report back the behavior observed?

---

<div class="post-metadata">

**Author:** ![pradeep07](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pradeep07](https://discuss.zetetic.net/u/pradeep07)\
**Post date:** [February 8, 2023, 5:51pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/11 "2023-02-08T17:51:23Z")

</div>

sure will try but in this case it’s not calling the lock() and unlock() methods correct? unlike in previous versions there was locking around finalizer so would call setLockingEnabled(false) have any affect?

Will give this try anyways and see

Thanks,

Pradeep

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [February 8, 2023, 7:51pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/12 "2023-02-08T19:51:17Z")

</div>

Hi @pradeep07,

Correct, the Java locking on the database was removed surrounding the call to `native_finalize()` for the purposes of finalizing the internal `sqlite3_stmt`, however, since the lock still exists within the `SQLiteDatabase` instance, it would be good to verify it isn’t causing a conflict for your use case.

---

<div class="post-metadata">

**Author:** ![pradeep07](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pradeep07](https://discuss.zetetic.net/u/pradeep07)\
**Post date:** [February 10, 2023, 2:34pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/13 "2023-02-10T14:34:03Z")

</div>

Thanks for the clarification. I haven’t been able to reproduce yet in my environment yet. Waiting to try in another environment where it was reproducible a lot and will confirm

Thanks,

Pradeep

---

<div class="post-metadata">

**Author:** ![pradeep07](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pradeep07](https://discuss.zetetic.net/u/pradeep07)\
**Post date:** [April 4, 2023, 12:56am UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/14 "2023-04-04T00:56:11Z")

</div>

Sorry for the delay, but we were able to reproduce with setLockingEnabled(false) as well on the android device.

java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds  
at net.sqlcipher.database.SQLiteCompiledSql.native\_finalize(Native Method) ~[na:0.0]  
at net.sqlcipher.database.SQLiteCompiledSql.releaseSqlStatement(SQLiteCompiledSql.java:103) ~[na:0.0]  
at net.sqlcipher.database.SQLiteCompiledSql.finalize(SQLiteCompiledSql.java:141) ~[na:0.0]  
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:202) ~[na:0.0]  
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:185) ~[na:0.0]  
at java.lang.Thread.run(Thread.java:818) ~[na:0.0]

We do have parallel threads reading and writing to the db just FYI

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [April 4, 2023, 1:09pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/15 "2023-04-04T13:09:24Z")

</div>

Hello @pradeep07,

Since it sounds as if you are using the SQLCipher for Android legacy library, if you would please submit a pull request with a new test case which reproduces the behavior in the [test suite](https://github.com/sqlcipher/sqlcipher-android-tests), we would be happy to look into this further. Thanks!

---

<div class="post-metadata">

**Author:** ![pradeep07](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pradeep07](https://discuss.zetetic.net/u/pradeep07)\
**Post date:** [April 4, 2023, 1:44pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/16 "2023-04-04T13:44:03Z")

</div>

Thanks I’ll take at seeing if i can add a testcase. One question I don’t have WAL enabled is that necessary? Or should i also try to increase the timeout? I have seen in previous posts that increasing the timeout did not take an effect?

Thanks,

Pradeep

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [April 4, 2023, 8:29pm UTC](https://discuss.zetetic.net/t/sqlcipher-for-android-refresh-beta/5405/17 "2023-04-04T20:29:28Z")

</div>

Hi @pradeep07,

You do not necessarily need to use WAL, however, in concurrent usage of SQLCipher, WAL provides more concurrency as readers do not block writers and writers do not block readers. WAL can be faster in most scenarios. It will be helpful to review the public test case to better understand the situation.
