Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite & Android: unable to open database file - error 14

I saw that a similar issue has been reported many times. In my case, I'm directly using the "C" API invoked using my own JNI library (not the Android Java layer), with the latest amalgamation 3.8.3. So I control what I'm dealing with. Then, on certain operations (UPDATE) I'm getting an error stating that it cannot open a database file. I don't get that with INSERT statements, only UPDATE. When I activate the SQLite error callback, I'm seeing the following:

cannot open file at line 29299 of [6c643e45c2] os_unix.c: 29299: (13) open(./etilqs_1zMsiYdpXhd3JqY) - statements aborts at 36: [UPDATE .....]

Digging this a little bit further, it appears to be related to the journal file. When I set the journal_mode to MEMORY using a pragma, then the issue disappears. But all the other modes, like WAL or TRUNCATED lead to the same error.

When debugging the code from eclipse, I can see the -journal file being created when performing the INSERT. And then being removed when the transaction is complete. So it tells me that it has enough rights on the directory (/data/data//)

Note that the exact same code works perfectly (C & Java) on Windows, where I'm not getting the error. There is definitively something going on with Android and file access.

I have a way to get the error reproduced systematically. If someone has some idea on what I should check, then I'll be happy to run some experiment and report the result.

like image 464
Philippe Riand Avatar asked Jul 29 '26 22:07

Philippe Riand


1 Answers

Too late answer..

I saw same problem, when using multi-thread.

Send next statement query in your first query.

PRAGMA temp_store_directory = 'some writeable path'

SQLITE3 Document says "deprecated", but.. this works for me..

Is really deprecated??

good luck..

ps. my sqlite3 version is [sqlite-amalgamation-3100200]

like image 121
james park Avatar answered Jul 31 '26 11:07

james park



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!