Android - How to Use SQLiteDatabase.open?
<p>i'm trying to use</p>

<pre><code>SQLiteDatabase.openDatabase(
    "/data/data/edwin11.myapp/databases/myapp.db", null, (SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.NO_LOCALIZED_COLLATORS));
</code></pre>

<p>to create/open a database instead of making use of the SQLiteOpenHelper (because i want to pass in the flag <code>SQLiteDatabase.NO_LOCALIZED_COLLATORS</code>.</p>

<p>However, i am getting this exception for that line of code:</p>

<pre><code>04-18 09:50:03.585: ERROR/Database(3471): sqlite3_open_v2("/data/data/edwin11.myapp/databases/myapp.db", &amp;handle, 6, NULL) failed
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): java.lang.RuntimeException: An error occured while executing doInBackground()
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:234)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:258)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at java.util.concurrent.FutureTask.run(FutureTask.java:122)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at java.lang.Thread.run(Thread.java:1060)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): Caused by: android.database.sqlite.SQLiteException: unable to open database file
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at android.database.sqlite.SQLiteDatabase.&lt;init&gt;(SQLiteDatabase.java:1584)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:638)
...
</code></pre>

<p>Doing some testing just before that line of code (using <code>File.isExists</code>) shows that the file <code>/data/data/edwin11.myapp/databases/myapp.db</code> does not exist.</p>

<p>Would that be the cause of the error? (Or am i just using <code>SQLiteDatabase.openDatabase</code> the wrong way?)</p>

<p>Would it help if i create the file beforehand? (Shouldn't that be taken care of by the <code>SQLiteDatabase.CREATE_IF_NECESSARY</code> flag that i passed in?)</p>

<p>If creating the file manually is the way to go, is it just an empty file, or do i have to write something to it?</p>

<p>Thanks and Regards.</p>
