3

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.

5
  • This is a temporary file. How did you configure the temp path of your copy of the SQLite library? Commented Feb 11, 2014 at 11:10
  • I didn't do any configuration. I see the journal file being created in the same directory than the DB when INSERT are performed. But it fails when executing UPDATE. Commented Feb 11, 2014 at 15:32
  • This is not a journal file. it is a temporary file. And the current directory (./) is not necessarily that of the database file. Commented Feb 11, 2014 at 16:06
  • right, but I can see the -journal file created from the File explorer in Eclipse during the processing of the transaction. Commented Feb 11, 2014 at 16:31
  • You must visit the [Link][1]. It will definately solve your problem. Thanks [1]: stackoverflow.com/questions/17034511/… Commented May 7, 2015 at 5:25

1 Answer 1

2

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]

Sign up to request clarification or add additional context in comments.

3 Comments

It's correct, just take a look at the source code that relate to etilqs, sqlite store its temp file to /tmp, /usr/tmp, but Android did not have that folder. Use this deprecated API seems to be the only answer. (There are lots of ways that sqlite might use temp directory, so just put this inside the onConfigure method, that should solve lots of problems).
That worked for me. I'm actually setting the temp path to the parent directory of the database and it works. I'll submit an issue to the SQLite team.
But in the app already have many database then how we can decide which database or where to include this statement ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.