SQLite Android Bindings

Check-in [97dc797d2f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update SQLiteOpenHelper.java to allow relative paths.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 97dc797d2f1c589d928351f3b87dab2621d76175
User & Date: dan 2021-09-18 18:11:33
Context
2021-11-27
15:09
Upgrade to 3.37.0. (Leaf check-in: 80f3cca97f user: dan tags: trunk)
2021-09-18
18:11
Update SQLiteOpenHelper.java to allow relative paths. (check-in: 97dc797d2f user: dan tags: trunk)
2021-06-18
18:56
Update this project to version 3.36.0. (check-in: d49b327e8f user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to sqlite3/src/main/java/org/sqlite/database/sqlite/SQLiteOpenHelper.java.

246
247
248
249
250
251
252




253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
            if (db != null) {
                if (writable && db.isReadOnly()) {
                    db.reopenReadWrite();
                }
            } else if (mName == null) {
                db = SQLiteDatabase.create(null);
            } else {




                try {
                    if (DEBUG_STRICT_READONLY && !writable) {
                        final String path = mContext.getDatabasePath(mName).getPath();
                        db = SQLiteDatabase.openDatabase(path, mFactory,
                                SQLiteDatabase.OPEN_READONLY, mErrorHandler);
                    } else {
                        db = SQLiteDatabase.openOrCreateDatabase(
                            mName, mFactory, mErrorHandler
                        );
                    }
                } catch (SQLiteException ex) {
                    if (writable) {
                        throw ex;
                    }
                    Log.e(TAG, "Couldn't open " + mName
                            + " for writing (will try read-only):", ex);
                    final String path = mContext.getDatabasePath(mName).getPath();
                    db = SQLiteDatabase.openDatabase(path, mFactory,
                            SQLiteDatabase.OPEN_READONLY, mErrorHandler);
                }
            }

            onConfigure(db);








>
>
>
>


<




|








<







246
247
248
249
250
251
252
253
254
255
256
257
258

259
260
261
262
263
264
265
266
267
268
269
270
271

272
273
274
275
276
277
278
            if (db != null) {
                if (writable && db.isReadOnly()) {
                    db.reopenReadWrite();
                }
            } else if (mName == null) {
                db = SQLiteDatabase.create(null);
            } else {
                String path = mName;
                if (!path.startsWith("file:")) {
                  path = mContext.getDatabasePath(path).getPath();
                }
                try {
                    if (DEBUG_STRICT_READONLY && !writable) {

                        db = SQLiteDatabase.openDatabase(path, mFactory,
                                SQLiteDatabase.OPEN_READONLY, mErrorHandler);
                    } else {
                        db = SQLiteDatabase.openOrCreateDatabase(
                            path, mFactory, mErrorHandler
                        );
                    }
                } catch (SQLiteException ex) {
                    if (writable) {
                        throw ex;
                    }
                    Log.e(TAG, "Couldn't open " + mName
                            + " for writing (will try read-only):", ex);

                    db = SQLiteDatabase.openDatabase(path, mFactory,
                            SQLiteDatabase.OPEN_READONLY, mErrorHandler);
                }
            }

            onConfigure(db);