SQLite Android Bindings
Check-in [c45018804a]
Not logged in

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

Overview
Comment:Do not automatically delete database files in SEE-enabled builds.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c45018804a67160dac06ca5269ac16d2192ffa5d
User & Date: dan 2013-12-25 19:13:11
Context
2013-12-26
17:31
Disable connection pooling in SQLITE_HAS_CODEC builds. Add a test for the same. check-in: 954e5a58f1 user: dan tags: trunk
2013-12-25
19:13
Do not automatically delete database files in SEE-enabled builds. check-in: c45018804a user: dan tags: trunk
19:03
Move c/c++ code into the jni/sqlite/ sub-directory. To make it easier to copy into other projects. check-in: 938b5766d5 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to src/org/sqlite/app/customsqlite/CustomSqlite.java.

193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
    db.execSQL("PRAGMA key = 'secretkey'");
    res = string_from_t1_x(db);
    test_result("see_test_1.3", res, ".one.two.three");
    db.close();

    res = "unencrypted";
    try {
      db = SQLiteDatabase.openOrCreateDatabase(
	  DB_PATH.getPath(), null, new DoNotDeleteErrorHandler()
      );
      string_from_t1_x(db);
    } catch ( SQLiteDatabaseCorruptException e ){
      res = "encrypted";
    } finally {
      db.close();
    }
    test_result("see_test_1.4", res, "encrypted");

    res = "unencrypted";
    try {
      db = SQLiteDatabase.openOrCreateDatabase(
	  DB_PATH.getPath(), null, new DoNotDeleteErrorHandler()
      );
      db.execSQL("PRAGMA key = 'otherkey'");
      string_from_t1_x(db);
    } catch ( SQLiteDatabaseCorruptException e ){
      res = "encrypted";
    } finally {
      db.close();
    }







|
<
<










|
<
<







193
194
195
196
197
198
199
200


201
202
203
204
205
206
207
208
209
210
211


212
213
214
215
216
217
218
    db.execSQL("PRAGMA key = 'secretkey'");
    res = string_from_t1_x(db);
    test_result("see_test_1.3", res, ".one.two.three");
    db.close();

    res = "unencrypted";
    try {
      db = SQLiteDatabase.openOrCreateDatabase(DB_PATH.getPath(), null);


      string_from_t1_x(db);
    } catch ( SQLiteDatabaseCorruptException e ){
      res = "encrypted";
    } finally {
      db.close();
    }
    test_result("see_test_1.4", res, "encrypted");

    res = "unencrypted";
    try {
      db = SQLiteDatabase.openOrCreateDatabase(DB_PATH.getPath(), null);


      db.execSQL("PRAGMA key = 'otherkey'");
      string_from_t1_x(db);
    } catch ( SQLiteDatabaseCorruptException e ){
      res = "encrypted";
    } finally {
      db.close();
    }

Changes to src/org/sqlite/database/DefaultDatabaseErrorHandler.java.

48
49
50
51
52
53
54




55
56
57
58
59
60
61
    /**
     * defines the default method to be invoked when database corruption is detected.
     * @param dbObj the {@link SQLiteDatabase} object representing the database on which corruption
     * is detected.
     */
    public void onCorruption(SQLiteDatabase dbObj) {
        Log.e(TAG, "Corruption reported by sqlite on database: " + dbObj.getPath());





        // is the corruption detected even before database could be 'opened'?
        if (!dbObj.isOpen()) {
            // database files are not even openable. delete this database file.
            // NOTE if the database has attached databases, then any of them could be corrupt.
            // and not deleting all of them could cause corrupted database file to remain and 
            // make the application crash on database open operation. To avoid this problem,







>
>
>
>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    /**
     * defines the default method to be invoked when database corruption is detected.
     * @param dbObj the {@link SQLiteDatabase} object representing the database on which corruption
     * is detected.
     */
    public void onCorruption(SQLiteDatabase dbObj) {
        Log.e(TAG, "Corruption reported by sqlite on database: " + dbObj.getPath());

	// If this is a SEE build, do not delete any database files.
	//
	if( SQLiteDatabase.hasCodec() ) return;

        // is the corruption detected even before database could be 'opened'?
        if (!dbObj.isOpen()) {
            // database files are not even openable. delete this database file.
            // NOTE if the database has attached databases, then any of them could be corrupt.
            // and not deleting all of them could cause corrupted database file to remain and 
            // make the application crash on database open operation. To avoid this problem,