| 4 |
| sqlite3 *handle = (sqlite3 *)sqliteHandle; |
| 5 | int err = sqlite3_close(handle); |
| 6 | if (SQLITE_OK != err) { |
| 7 | throw_sqlite3_exception(env, handle, err); |
| 8 | } |
| 9 | } |
| 10 |
| 11 | void Java_org_telegram_SQLite_SQLiteDatabase_beginTransaction(JNIEnv *env, jobject object, int sqliteHandle) { |
| 12 | sqlite3 *handle = (sqlite3 *)sqliteHandle; |
| 13 | sqlite3_exec(handle, "BEGIN", 0, 0, 0); |
| 14 | } |
| 15 |
| 16 | void Java_org_telegram_SQLite_SQLiteDatabase_commitTransaction(JNIEnv *env, jobject object, int sqliteHandle) { |
| 17 | sqlite3 *handle = (sqlite3 *)sqliteHandle; |
| 18 | sqlite3_exec(handle, "COMMIT", 0, 0, 0); |
| 19 | } |
| 20 |
| 21 | int Java_org_telegram_SQLite_SQLiteDatabase_opendb(JNIEnv *env, jobject object, jstring fileName, jstring tempDir) { |
| 22 | char const *fileNameStr = (*env)->GetStringUTFChars(env, fileName, 0); |
| 23 | char const *tempDirStr = (*env)->GetStringUTFChars(env, tempDir, 0); |
| 24 |
| 25 | if (sqlite3_temp_directory != 0) { |
| 26 | sqlite3_free(sqlite3_temp_directory); |
| 27 | } |
| 28 | sqlite3_temp_directory = sqlite3_mprintf("%s", tempDirStr); |
| 29 |
| 30 | sqlite3 *handle = 0; |
| 31 | int err = sqlite3_open(fileNameStr, &handle); |
| 32 | if (SQLITE_OK != err) { |
| 33 | throw_sqlite3_exception(env, handle, err); |
| 34 | } |
| 35 | if (fileNameStr != 0) { |
| 36 | (*env)->ReleaseStringUTFChars(env, fileName, fileNameStr); |
| 37 | } |
| 38 | if (tempDirStr != 0) { |
| 39 | (*env)->ReleaseStringUTFChars(env, tempDir, tempDirStr); |
| 40 | } |
| 41 | return (int)handle; |
| 42 | } |
| 43 |