@capacitor-community/sqlite 6.0.2 → 7.0.0-dev.bf54d28.1747847115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorCommunitySqlite.podspec +1 -1
- package/README.md +6 -6
- package/android/build.gradle +9 -9
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +11 -13
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +3 -6
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +10 -16
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ExportToJson.java +5 -6
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +63 -67
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsBiometric.java +27 -31
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsDrop.java +9 -9
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsFile.java +2 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLCipher.java +23 -16
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLite.java +3 -3
- package/dist/esm/definitions.js.map +1 -1
- package/dist/plugin.cjs.js +0 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +0 -2
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +6197 -6076
- package/electron/dist/plugin.js.map +1 -1
- package/package.json +20 -20
- package/src/definitions.ts +11 -7
- package/src/web.ts +1 -1
- /package/electron/{rollup.config.js → rollup.config.mjs} +0 -0
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.dependency 'SQLCipher'
|
|
17
17
|
s.dependency 'ZIPFoundation'
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
</p>
|
|
11
11
|
<br>
|
|
12
12
|
<p align="center">
|
|
13
|
-
<img src="https://img.shields.io/maintenance/yes/
|
|
13
|
+
<img src="https://img.shields.io/maintenance/yes/2025?style=flat-square" />
|
|
14
14
|
<a href="https://github.com/capacitor-community/sqlite/actions?query=workflow%3A%22CI%22"><img src="https://img.shields.io/github/actions/workflow/status/capacitor-community/sqlite/ci.yml?style=flat-square" /></a>
|
|
15
15
|
<a href="https://www.npmjs.com/package/@capacitor-community/sqlite"><img src="https://img.shields.io/npm/l/@capacitor-community/sqlite?branch=master&style=flat-square" /></a>
|
|
16
16
|
<br>
|
|
@@ -131,14 +131,14 @@ You'll need the usual capacitor/android/react npm script to build and copy the a
|
|
|
131
131
|
See [#301](https://github.com/capacitor-community/sqlite/issues/301) and [SO question](https://stackoverflow.com/questions/63291529/how-to-fix-more-than-one-file-was-found-with-os-independent-path-build-data-pro) for more information.
|
|
132
132
|
|
|
133
133
|
- Check/Add the following:
|
|
134
|
-
Gradle JDK version
|
|
135
|
-
Android Gradle Plugin Version 8.
|
|
134
|
+
Gradle JDK version 21
|
|
135
|
+
Android Gradle Plugin Version 8.7.2
|
|
136
136
|
In variables.gradle
|
|
137
137
|
|
|
138
138
|
```
|
|
139
|
-
minSdkVersion =
|
|
140
|
-
compileSdkVersion =
|
|
141
|
-
targetSdkVersion =
|
|
139
|
+
minSdkVersion = 23
|
|
140
|
+
compileSdkVersion = 35
|
|
141
|
+
targetSdkVersion = 35
|
|
142
142
|
```
|
|
143
143
|
In AndroidManifest.xml
|
|
144
144
|
```
|
package/android/build.gradle
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
ext {
|
|
2
2
|
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
-
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.
|
|
4
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1
|
|
5
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
@@ -19,13 +19,13 @@ apply plugin: 'com.android.library'
|
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
21
|
namespace "com.getcapacitor.community.database.sqlite"
|
|
22
|
-
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
23
|
packagingOptions {
|
|
24
24
|
exclude 'build-data.properties'
|
|
25
25
|
}
|
|
26
26
|
defaultConfig {
|
|
27
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
28
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
27
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
28
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
29
29
|
versionCode 1
|
|
30
30
|
versionName "1.0"
|
|
31
31
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -40,8 +40,8 @@ android {
|
|
|
40
40
|
abortOnError false
|
|
41
41
|
}
|
|
42
42
|
compileOptions {
|
|
43
|
-
sourceCompatibility JavaVersion.
|
|
44
|
-
targetCompatibility JavaVersion.
|
|
43
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
44
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -61,7 +61,7 @@ dependencies {
|
|
|
61
61
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
62
62
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
63
63
|
implementation "androidx.coordinatorlayout:coordinatorlayout:1.2.0"
|
|
64
|
-
implementation 'net.zetetic:android
|
|
64
|
+
implementation 'net.zetetic:sqlcipher-android:4.6.1@aar'
|
|
65
65
|
implementation "androidx.sqlite:sqlite:2.4.0"
|
|
66
66
|
//security library
|
|
67
67
|
implementation "androidx.security:security-crypto:1.1.0-alpha06"
|
package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java
CHANGED
|
@@ -92,11 +92,10 @@ public class CapacitorSQLite {
|
|
|
92
92
|
ks.load(null);
|
|
93
93
|
Enumeration<String> aliases = ks.aliases();
|
|
94
94
|
if (aliases.hasMoreElements()) {
|
|
95
|
-
masterKeyAlias =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
.build();
|
|
95
|
+
masterKeyAlias = new MasterKey.Builder(context)
|
|
96
|
+
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
|
|
97
|
+
.setUserAuthenticationRequired(true, VALIDITY_DURATION)
|
|
98
|
+
.build();
|
|
100
99
|
} else {
|
|
101
100
|
masterKeyAlias = new MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build();
|
|
102
101
|
}
|
|
@@ -149,14 +148,13 @@ public class CapacitorSQLite {
|
|
|
149
148
|
private void setSharedPreferences() throws Exception {
|
|
150
149
|
try {
|
|
151
150
|
// get instance of the EncryptedSharedPreferences class
|
|
152
|
-
this.sharedPreferences =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
151
|
+
this.sharedPreferences = EncryptedSharedPreferences.create(
|
|
152
|
+
context,
|
|
153
|
+
"sqlite_encrypted_shared_prefs",
|
|
154
|
+
masterKeyAlias,
|
|
155
|
+
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
|
156
|
+
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
|
157
|
+
);
|
|
160
158
|
this.uSecret = new UtilsSecret(this.context, this.sharedPreferences);
|
|
161
159
|
} catch (Exception e) {
|
|
162
160
|
throw new Exception(e.getMessage());
|
package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java
CHANGED
|
@@ -1549,8 +1549,7 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
1549
1549
|
}
|
|
1550
1550
|
|
|
1551
1551
|
private void AddObserversToNotificationCenter() {
|
|
1552
|
-
NotificationCenter
|
|
1553
|
-
.defaultCenter()
|
|
1552
|
+
NotificationCenter.defaultCenter()
|
|
1554
1553
|
.addMethodForNotification(
|
|
1555
1554
|
"importJsonProgress",
|
|
1556
1555
|
new MyRunnable() {
|
|
@@ -1562,8 +1561,7 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
1562
1561
|
}
|
|
1563
1562
|
}
|
|
1564
1563
|
);
|
|
1565
|
-
NotificationCenter
|
|
1566
|
-
.defaultCenter()
|
|
1564
|
+
NotificationCenter.defaultCenter()
|
|
1567
1565
|
.addMethodForNotification(
|
|
1568
1566
|
"exportJsonProgress",
|
|
1569
1567
|
new MyRunnable() {
|
|
@@ -1575,8 +1573,7 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
1575
1573
|
}
|
|
1576
1574
|
}
|
|
1577
1575
|
);
|
|
1578
|
-
NotificationCenter
|
|
1579
|
-
.defaultCenter()
|
|
1576
|
+
NotificationCenter.defaultCenter()
|
|
1580
1577
|
.addMethodForNotification(
|
|
1581
1578
|
"biometricResults",
|
|
1582
1579
|
new MyRunnable() {
|
package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java
CHANGED
|
@@ -26,6 +26,7 @@ import com.getcapacitor.community.database.sqlite.SQLite.ImportExportJson.JsonSQ
|
|
|
26
26
|
import com.getcapacitor.community.database.sqlite.SQLite.ImportExportJson.UtilsEncryption;
|
|
27
27
|
import com.getcapacitor.community.database.sqlite.SQLite.ImportExportJson.UtilsJson;
|
|
28
28
|
import java.io.File;
|
|
29
|
+
import java.nio.charset.StandardCharsets;
|
|
29
30
|
import java.text.SimpleDateFormat;
|
|
30
31
|
import java.util.ArrayList;
|
|
31
32
|
import java.util.Arrays;
|
|
@@ -35,9 +36,8 @@ import java.util.List;
|
|
|
35
36
|
import java.util.Objects;
|
|
36
37
|
import java.util.regex.Matcher;
|
|
37
38
|
import java.util.regex.Pattern;
|
|
38
|
-
import net.sqlcipher.
|
|
39
|
-
import net.
|
|
40
|
-
import net.sqlcipher.database.SQLiteException;
|
|
39
|
+
import net.zetetic.database.sqlcipher.SQLiteCursor;
|
|
40
|
+
import net.zetetic.database.sqlcipher.SQLiteDatabase;
|
|
41
41
|
import org.json.JSONArray;
|
|
42
42
|
import org.json.JSONException;
|
|
43
43
|
import org.json.JSONObject;
|
|
@@ -115,7 +115,7 @@ public class Database {
|
|
|
115
115
|
* Initialize the SQLCipher Libraries
|
|
116
116
|
*/
|
|
117
117
|
private void InitializeSQLCipher() {
|
|
118
|
-
|
|
118
|
+
System.loadLibrary("sqlcipher");
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
public SupportSQLiteDatabase getDb() {
|
|
@@ -247,7 +247,7 @@ public class Database {
|
|
|
247
247
|
if (_mode.equals("encryption")) {
|
|
248
248
|
if (_isEncryption) {
|
|
249
249
|
try {
|
|
250
|
-
_uCipher.encrypt(_context, _file,
|
|
250
|
+
_uCipher.encrypt(_context, _file, password.getBytes(StandardCharsets.UTF_8));
|
|
251
251
|
} catch (Exception e) {
|
|
252
252
|
String msg = "Failed in encryption " + e.getMessage();
|
|
253
253
|
Log.v(TAG, msg);
|
|
@@ -260,7 +260,7 @@ public class Database {
|
|
|
260
260
|
if (_mode.equals("decryption")) {
|
|
261
261
|
if (_isEncryption) {
|
|
262
262
|
try {
|
|
263
|
-
_uCipher.decrypt(_context, _file,
|
|
263
|
+
_uCipher.decrypt(_context, _file, password.getBytes());
|
|
264
264
|
password = "";
|
|
265
265
|
} catch (Exception e) {
|
|
266
266
|
String msg = "Failed in decryption " + e.getMessage();
|
|
@@ -273,9 +273,9 @@ public class Database {
|
|
|
273
273
|
}
|
|
274
274
|
try {
|
|
275
275
|
if (!isNCDB() && !this._readOnly) {
|
|
276
|
-
_db = SQLiteDatabase.openOrCreateDatabase(_file, password, null);
|
|
276
|
+
_db = SQLiteDatabase.openOrCreateDatabase(_file, password, null, null);
|
|
277
277
|
} else {
|
|
278
|
-
_db = SQLiteDatabase.openDatabase(String.valueOf(_file), password, null, SQLiteDatabase.OPEN_READONLY);
|
|
278
|
+
_db = SQLiteDatabase.openDatabase(String.valueOf(_file), password, null, SQLiteDatabase.OPEN_READONLY, null);
|
|
279
279
|
}
|
|
280
280
|
if (_db != null) {
|
|
281
281
|
if (_db.isOpen()) {
|
|
@@ -301,12 +301,6 @@ public class Database {
|
|
|
301
301
|
close();
|
|
302
302
|
_db = null;
|
|
303
303
|
throw new Exception(msg);
|
|
304
|
-
} catch (SQLiteException e) {
|
|
305
|
-
String msg = "Failed in setVersion " + e.getMessage();
|
|
306
|
-
Log.v(TAG, msg);
|
|
307
|
-
close();
|
|
308
|
-
_db = null;
|
|
309
|
-
throw new Exception(msg);
|
|
310
304
|
}
|
|
311
305
|
if (_version > curVersion && _vUpgObject != null && _vUpgObject.size() > 0) {
|
|
312
306
|
// if (_vUpgObject != null && _vUpgObject.size() > 0) {
|
|
@@ -973,12 +967,12 @@ public class Database {
|
|
|
973
967
|
*/
|
|
974
968
|
public JSArray selectSQL(String statement, ArrayList<Object> values) throws Exception {
|
|
975
969
|
JSArray retArray = new JSArray();
|
|
976
|
-
|
|
970
|
+
SQLiteCursor c = null;
|
|
977
971
|
if (_db == null) {
|
|
978
972
|
return retArray;
|
|
979
973
|
}
|
|
980
974
|
try {
|
|
981
|
-
c = (
|
|
975
|
+
c = (SQLiteCursor) _db.query(statement, values.toArray(new Object[0]));
|
|
982
976
|
while (c.moveToNext()) {
|
|
983
977
|
JSObject row = new JSObject();
|
|
984
978
|
for (int i = 0; i < c.getColumnCount(); i++) {
|
|
@@ -164,12 +164,11 @@ public class ExportToJson {
|
|
|
164
164
|
throw new Exception("No sync_table available");
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
tables =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
167
|
+
tables = switch (sqlObj.getMode()) {
|
|
168
|
+
case "partial" -> getTablesPartial(db, resTables);
|
|
169
|
+
case "full" -> getTablesFull(db, resTables);
|
|
170
|
+
default -> throw new Exception("CreateExportObject: expMode " + sqlObj.getMode() + " not defined");
|
|
171
|
+
};
|
|
173
172
|
if (tables.size() > 0) {
|
|
174
173
|
retObj.setDatabase(sqlObj.getDatabase());
|
|
175
174
|
retObj.setVersion(sqlObj.getVersion());
|
|
@@ -165,8 +165,11 @@ public class ImportFromJson {
|
|
|
165
165
|
for (int j = 0; j < mSchema.size(); j++) {
|
|
166
166
|
if (j == mSchema.size() - 1) {
|
|
167
167
|
if (mSchema.get(j).getColumn() != null) {
|
|
168
|
-
stmt =
|
|
169
|
-
|
|
168
|
+
stmt = new StringBuilder(stmt)
|
|
169
|
+
.append(mSchema.get(j).getColumn())
|
|
170
|
+
.append(" ")
|
|
171
|
+
.append(mSchema.get(j).getValue())
|
|
172
|
+
.toString();
|
|
170
173
|
if (mSchema.get(j).getColumn().equals("last_modified")) {
|
|
171
174
|
isLastModified = true;
|
|
172
175
|
}
|
|
@@ -174,31 +177,28 @@ public class ImportFromJson {
|
|
|
174
177
|
isSqlDeleted = true;
|
|
175
178
|
}
|
|
176
179
|
} else if (mSchema.get(j).getForeignkey() != null) {
|
|
177
|
-
stmt =
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
.toString();
|
|
180
|
+
stmt = new StringBuilder(stmt)
|
|
181
|
+
.append("FOREIGN KEY (")
|
|
182
|
+
.append(mSchema.get(j).getForeignkey())
|
|
183
|
+
.append(") ")
|
|
184
|
+
.append(mSchema.get(j).getValue())
|
|
185
|
+
.toString();
|
|
184
186
|
} else if (mSchema.get(j).getConstraint() != null) {
|
|
185
|
-
stmt =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
.toString();
|
|
187
|
+
stmt = new StringBuilder(stmt)
|
|
188
|
+
.append("CONSTRAINT ")
|
|
189
|
+
.append(mSchema.get(j).getConstraint())
|
|
190
|
+
.append(" ")
|
|
191
|
+
.append(mSchema.get(j).getValue())
|
|
192
|
+
.toString();
|
|
192
193
|
}
|
|
193
194
|
} else {
|
|
194
195
|
if (mSchema.get(j).getColumn() != null) {
|
|
195
|
-
stmt =
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
.toString();
|
|
196
|
+
stmt = new StringBuilder(stmt)
|
|
197
|
+
.append(mSchema.get(j).getColumn())
|
|
198
|
+
.append(" ")
|
|
199
|
+
.append(mSchema.get(j).getValue())
|
|
200
|
+
.append(",")
|
|
201
|
+
.toString();
|
|
202
202
|
if (mSchema.get(j).getColumn().equals("last_modified")) {
|
|
203
203
|
isLastModified = true;
|
|
204
204
|
}
|
|
@@ -206,23 +206,21 @@ public class ImportFromJson {
|
|
|
206
206
|
isSqlDeleted = true;
|
|
207
207
|
}
|
|
208
208
|
} else if (mSchema.get(j).getForeignkey() != null) {
|
|
209
|
-
stmt =
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
.toString();
|
|
209
|
+
stmt = new StringBuilder(stmt)
|
|
210
|
+
.append("FOREIGN KEY (")
|
|
211
|
+
.append(mSchema.get(j).getForeignkey())
|
|
212
|
+
.append(") ")
|
|
213
|
+
.append(mSchema.get(j).getValue())
|
|
214
|
+
.append(",")
|
|
215
|
+
.toString();
|
|
217
216
|
} else if (mSchema.get(j).getConstraint() != null) {
|
|
218
|
-
stmt =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
.toString();
|
|
217
|
+
stmt = new StringBuilder(stmt)
|
|
218
|
+
.append("CONSTRAINT ")
|
|
219
|
+
.append(mSchema.get(j).getConstraint())
|
|
220
|
+
.append(" ")
|
|
221
|
+
.append(mSchema.get(j).getValue())
|
|
222
|
+
.append(",")
|
|
223
|
+
.toString();
|
|
226
224
|
}
|
|
227
225
|
}
|
|
228
226
|
}
|
|
@@ -587,16 +585,15 @@ public class ImportFromJson {
|
|
|
587
585
|
if (questionMarkString.length() == 0) {
|
|
588
586
|
throw new Exception(msg + j + "questionMarkString is empty");
|
|
589
587
|
}
|
|
590
|
-
stmt =
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
.toString();
|
|
588
|
+
stmt = new StringBuilder("INSERT INTO ")
|
|
589
|
+
.append(tableName)
|
|
590
|
+
.append("(")
|
|
591
|
+
.append(namesString)
|
|
592
|
+
.append(")")
|
|
593
|
+
.append(" VALUES (")
|
|
594
|
+
.append(questionMarkString)
|
|
595
|
+
.append(");")
|
|
596
|
+
.toString();
|
|
600
597
|
} else {
|
|
601
598
|
Boolean isUpdate = true;
|
|
602
599
|
Integer idxDelete = tColNames.indexOf("sql_deleted");
|
|
@@ -741,25 +738,24 @@ public class ImportFromJson {
|
|
|
741
738
|
if (colIndex == -1 || (int) rowIndex.get(colIndex) == 0) {
|
|
742
739
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
743
740
|
String formattedRow = null;
|
|
744
|
-
formattedRow =
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
rVal = val.replace("'", "''");
|
|
755
|
-
}
|
|
756
|
-
return "'" + rVal + "'";
|
|
757
|
-
} else {
|
|
758
|
-
return item.toString();
|
|
741
|
+
formattedRow = String.join(
|
|
742
|
+
", ",
|
|
743
|
+
rowIndex
|
|
744
|
+
.stream()
|
|
745
|
+
.map(item -> {
|
|
746
|
+
if (item instanceof String) {
|
|
747
|
+
String val = (String) item;
|
|
748
|
+
String rVal = val;
|
|
749
|
+
if (val.contains("'")) {
|
|
750
|
+
rVal = val.replace("'", "''");
|
|
759
751
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
752
|
+
return "'" + rVal + "'";
|
|
753
|
+
} else {
|
|
754
|
+
return item.toString();
|
|
755
|
+
}
|
|
756
|
+
})
|
|
757
|
+
.toArray(String[]::new)
|
|
758
|
+
);
|
|
763
759
|
insertValues.append("(").append(formattedRow).append("), ");
|
|
764
760
|
} else {
|
|
765
761
|
StringBuilder formattedRow = new StringBuilder();
|
package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsBiometric.java
CHANGED
|
@@ -79,41 +79,37 @@ public class UtilsBiometric {
|
|
|
79
79
|
*/
|
|
80
80
|
private void setupBiometricPrompt(String biometricTitle, String biometricSubTitle) {
|
|
81
81
|
executor = ContextCompat.getMainExecutor(context);
|
|
82
|
-
biometricPrompt =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
82
|
+
biometricPrompt = new BiometricPrompt(
|
|
83
|
+
(FragmentActivity) context,
|
|
84
|
+
executor,
|
|
85
|
+
new BiometricPrompt.AuthenticationCallback() {
|
|
86
|
+
@Override
|
|
87
|
+
public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
|
|
88
|
+
super.onAuthenticationError(errorCode, errString);
|
|
89
|
+
Toast.makeText(context, "Authentication error: " + errString, Toast.LENGTH_SHORT).show();
|
|
90
|
+
listener.onFailed();
|
|
91
|
+
}
|
|
93
92
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
@Override
|
|
94
|
+
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
|
|
95
|
+
super.onAuthenticationSucceeded(result);
|
|
96
|
+
listener.onSuccess(result);
|
|
97
|
+
}
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
99
|
+
@Override
|
|
100
|
+
public void onAuthenticationFailed() {
|
|
101
|
+
super.onAuthenticationFailed();
|
|
102
|
+
Toast.makeText(context, "Authentication failed", Toast.LENGTH_SHORT).show();
|
|
103
|
+
listener.onFailed();
|
|
106
104
|
}
|
|
107
|
-
|
|
105
|
+
}
|
|
106
|
+
);
|
|
108
107
|
|
|
109
108
|
// Create prompt dialog
|
|
110
|
-
promptInfo =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
BiometricManager.Authenticators.BIOMETRIC_STRONG | BiometricManager.Authenticators.DEVICE_CREDENTIAL
|
|
116
|
-
)
|
|
117
|
-
.build();
|
|
109
|
+
promptInfo = new BiometricPrompt.PromptInfo.Builder()
|
|
110
|
+
.setTitle(biometricTitle)
|
|
111
|
+
.setSubtitle(biometricSubTitle)
|
|
112
|
+
.setAllowedAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG | BiometricManager.Authenticators.DEVICE_CREDENTIAL)
|
|
113
|
+
.build();
|
|
118
114
|
}
|
|
119
115
|
}
|
package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsDrop.java
CHANGED
|
@@ -6,7 +6,7 @@ import java.util.ArrayList;
|
|
|
6
6
|
import java.util.Dictionary;
|
|
7
7
|
import java.util.Enumeration;
|
|
8
8
|
import java.util.List;
|
|
9
|
-
import net.sqlcipher.
|
|
9
|
+
import net.zetetic.database.sqlcipher.SQLiteCursor;
|
|
10
10
|
|
|
11
11
|
public class UtilsDrop {
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ public class UtilsDrop {
|
|
|
20
20
|
|
|
21
21
|
public List<String> getTablesNames(Database db) throws Exception {
|
|
22
22
|
List<String> tables = new ArrayList<String>();
|
|
23
|
-
|
|
23
|
+
SQLiteCursor cursor = null;
|
|
24
24
|
String query = "SELECT name FROM sqlite_master WHERE ";
|
|
25
25
|
query += "type='table' AND name NOT LIKE 'sync_table' ";
|
|
26
26
|
query += "AND name NOT LIKE '_temp_%' ";
|
|
@@ -28,7 +28,7 @@ public class UtilsDrop {
|
|
|
28
28
|
query += "AND name NOT LIKE 'android_%' ";
|
|
29
29
|
query += "ORDER BY rootpage DESC;";
|
|
30
30
|
try {
|
|
31
|
-
cursor = (
|
|
31
|
+
cursor = (SQLiteCursor) db.getDb().query(query);
|
|
32
32
|
cursor.moveToFirst();
|
|
33
33
|
while (!cursor.isAfterLast()) {
|
|
34
34
|
String tableName = cursor.getString(0);
|
|
@@ -51,12 +51,12 @@ public class UtilsDrop {
|
|
|
51
51
|
|
|
52
52
|
public List<String> getViewNames(Database db) throws Exception {
|
|
53
53
|
List<String> views = new ArrayList<String>();
|
|
54
|
-
|
|
54
|
+
SQLiteCursor cursor = null;
|
|
55
55
|
String query = "SELECT name FROM sqlite_master WHERE ";
|
|
56
56
|
query += "type='view' AND name NOT LIKE 'sqlite_%' ";
|
|
57
57
|
query += "ORDER BY rootpage DESC;";
|
|
58
58
|
try {
|
|
59
|
-
cursor = (
|
|
59
|
+
cursor = (SQLiteCursor) db.getDb().query(query);
|
|
60
60
|
cursor.moveToFirst();
|
|
61
61
|
while (!cursor.isAfterLast()) {
|
|
62
62
|
String viewName = cursor.getString(0);
|
|
@@ -113,10 +113,10 @@ public class UtilsDrop {
|
|
|
113
113
|
|
|
114
114
|
public List<String> getIndexesNames(Database db) {
|
|
115
115
|
List<String> indexes = new ArrayList<String>();
|
|
116
|
-
|
|
116
|
+
SQLiteCursor cursor = null;
|
|
117
117
|
String query = "SELECT name FROM sqlite_master WHERE ";
|
|
118
118
|
query += "type='index' AND name NOT LIKE 'sqlite_%';";
|
|
119
|
-
cursor = (
|
|
119
|
+
cursor = (SQLiteCursor) db.getDb().query(query);
|
|
120
120
|
cursor.moveToFirst();
|
|
121
121
|
while (!cursor.isAfterLast()) {
|
|
122
122
|
String indexName = cursor.getString(0);
|
|
@@ -152,10 +152,10 @@ public class UtilsDrop {
|
|
|
152
152
|
|
|
153
153
|
public List<String> getTriggersNames(Database db) {
|
|
154
154
|
List<String> triggers = new ArrayList<String>();
|
|
155
|
-
|
|
155
|
+
SQLiteCursor cursor = null;
|
|
156
156
|
String query = "SELECT name FROM sqlite_master WHERE ";
|
|
157
157
|
query += "type='trigger';";
|
|
158
|
-
cursor = (
|
|
158
|
+
cursor = (SQLiteCursor) db.getDb().query(query);
|
|
159
159
|
cursor.moveToFirst();
|
|
160
160
|
while (!cursor.isAfterLast()) {
|
|
161
161
|
String triggerName = cursor.getString(0);
|
package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsFile.java
CHANGED
|
@@ -261,7 +261,8 @@ public class UtilsFile {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
public String getFileExtension(String name) {
|
|
264
|
-
if (name.lastIndexOf(".") != -1 && name.lastIndexOf(".") != 0) return name.substring(name.lastIndexOf(".") + 1);
|
|
264
|
+
if (name.lastIndexOf(".") != -1 && name.lastIndexOf(".") != 0) return name.substring(name.lastIndexOf(".") + 1);
|
|
265
|
+
else return "";
|
|
265
266
|
}
|
|
266
267
|
|
|
267
268
|
public Boolean restoreDatabase(Context context, String databaseName) {
|