@capacitor-community/sqlite 3.4.0-3 → 3.4.1-2

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.
Files changed (27) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -0
  3. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +125 -88
  4. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +449 -264
  5. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +41 -27
  6. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ExportToJson.java +5 -0
  7. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +24 -15
  8. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/JsonSQLite.java +4 -1
  9. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/UtilsJson.java +23 -0
  10. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/SqliteConfig.java +9 -0
  11. package/dist/esm/definitions.d.ts +14 -0
  12. package/dist/esm/definitions.js +55 -0
  13. package/dist/esm/definitions.js.map +1 -1
  14. package/dist/plugin.cjs.js +55 -0
  15. package/dist/plugin.cjs.js.map +1 -1
  16. package/dist/plugin.js +55 -0
  17. package/dist/plugin.js.map +1 -1
  18. package/electron/dist/plugin.js +228 -176
  19. package/electron/dist/plugin.js.map +1 -1
  20. package/ios/Plugin/CapacitorSQLite.swift +150 -109
  21. package/ios/Plugin/CapacitorSQLitePlugin.swift +17 -10
  22. package/ios/Plugin/Database.swift +51 -20
  23. package/ios/Plugin/ImportExportJson/ExportToJson.swift +8 -0
  24. package/ios/Plugin/ImportExportJson/ImportFromJson.swift +20 -14
  25. package/ios/Plugin/SqliteConfig.swift +1 -0
  26. package/ios/Plugin/Utils/UtilsJson.swift +28 -0
  27. package/package.json +10 -7
@@ -6,6 +6,7 @@ import com.getcapacitor.JSArray;
6
6
  import com.getcapacitor.JSObject;
7
7
  import com.getcapacitor.Plugin;
8
8
  import com.getcapacitor.PluginCall;
9
+ import com.getcapacitor.PluginConfig;
9
10
  import com.getcapacitor.PluginMethod;
10
11
  import com.getcapacitor.annotation.CapacitorPlugin;
11
12
  import com.getcapacitor.community.database.sqlite.SQLite.Database;
@@ -28,6 +29,7 @@ public class CapacitorSQLitePlugin extends Plugin {
28
29
  private RetHandler rHandler = new RetHandler();
29
30
  private String passphrase = null;
30
31
  private String oldpassphrase = null;
32
+ private String loadMessage = "";
31
33
 
32
34
  /**
33
35
  * Load Method
@@ -41,10 +43,12 @@ public class CapacitorSQLitePlugin extends Plugin {
41
43
  implementation = new CapacitorSQLite(context, config);
42
44
  } catch (JSONException e) {
43
45
  implementation = null;
44
- Log.e(TAG, "CapacitorSQLitePlugin: " + e.getMessage());
46
+ loadMessage = "CapacitorSQLitePlugin: " + e.getMessage();
47
+ Log.e(TAG, loadMessage);
45
48
  } catch (Exception e) {
46
49
  implementation = null;
47
- Log.e(TAG, "CapacitorSQLitePlugin: " + e.getMessage());
50
+ loadMessage = "CapacitorSQLitePlugin: " + e.getMessage();
51
+ Log.e(TAG, loadMessage);
48
52
  }
49
53
  }
50
54
 
@@ -57,12 +61,16 @@ public class CapacitorSQLitePlugin extends Plugin {
57
61
  @PluginMethod
58
62
  public void echo(PluginCall call) {
59
63
  String value = call.getString("value");
60
- try {
61
- JSObject ret = new JSObject();
62
- ret.put("value", implementation.echo(value));
63
- call.resolve(ret);
64
- } catch (Exception e) {
65
- call.reject(e.getMessage());
64
+ if (implementation != null) {
65
+ try {
66
+ JSObject ret = new JSObject();
67
+ ret.put("value", implementation.echo(value));
68
+ call.resolve(ret);
69
+ } catch (Exception e) {
70
+ call.reject(e.getMessage());
71
+ }
72
+ } else {
73
+ call.reject(loadMessage);
66
74
  }
67
75
  }
68
76
 
@@ -74,13 +82,18 @@ public class CapacitorSQLitePlugin extends Plugin {
74
82
  */
75
83
  @PluginMethod
76
84
  public void isSecretStored(PluginCall call) {
77
- try {
78
- Boolean res = implementation.isSecretStored();
79
- rHandler.retResult(call, res, null);
80
- return;
81
- } catch (Exception e) {
82
- String msg = "IsSecretStored: " + e.getMessage();
83
- rHandler.retResult(call, null, msg);
85
+ if (implementation != null) {
86
+ try {
87
+ Boolean res = implementation.isSecretStored();
88
+ rHandler.retResult(call, res, null);
89
+ return;
90
+ } catch (Exception e) {
91
+ String msg = "IsSecretStored: " + e.getMessage();
92
+ rHandler.retResult(call, null, msg);
93
+ return;
94
+ }
95
+ } else {
96
+ rHandler.retResult(call, null, loadMessage);
84
97
  return;
85
98
  }
86
99
  }
@@ -100,13 +113,18 @@ public class CapacitorSQLitePlugin extends Plugin {
100
113
  return;
101
114
  }
102
115
  passphrase = call.getString("passphrase");
103
- try {
104
- implementation.setEncryptionSecret(passphrase);
105
- rHandler.retResult(call, null, null);
106
- return;
107
- } catch (Exception e) {
108
- String msg = "SetEncryptionSecret: " + e.getMessage();
109
- rHandler.retResult(call, null, msg);
116
+ if (implementation != null) {
117
+ try {
118
+ implementation.setEncryptionSecret(passphrase);
119
+ rHandler.retResult(call, null, null);
120
+ return;
121
+ } catch (Exception e) {
122
+ String msg = "SetEncryptionSecret: " + e.getMessage();
123
+ rHandler.retResult(call, null, msg);
124
+ return;
125
+ }
126
+ } else {
127
+ rHandler.retResult(call, null, loadMessage);
110
128
  return;
111
129
  }
112
130
  }
@@ -133,22 +151,27 @@ public class CapacitorSQLitePlugin extends Plugin {
133
151
  return;
134
152
  }
135
153
  oldpassphrase = call.getString("oldpassphrase");
136
- getActivity()
137
- .runOnUiThread(
138
- new Runnable() {
139
- @Override
140
- public void run() {
141
- try {
142
- implementation.changeEncryptionSecret(call, passphrase, oldpassphrase);
143
- return;
144
- } catch (Exception e) {
145
- String msg = "ChangeEncryptionSecret: " + e.getMessage();
146
- rHandler.retResult(call, null, msg);
147
- return;
154
+ if (implementation != null) {
155
+ getActivity()
156
+ .runOnUiThread(
157
+ new Runnable() {
158
+ @Override
159
+ public void run() {
160
+ try {
161
+ implementation.changeEncryptionSecret(call, passphrase, oldpassphrase);
162
+ return;
163
+ } catch (Exception e) {
164
+ String msg = "ChangeEncryptionSecret: " + e.getMessage();
165
+ rHandler.retResult(call, null, msg);
166
+ return;
167
+ }
148
168
  }
149
169
  }
150
- }
151
- );
170
+ );
171
+ } else {
172
+ rHandler.retResult(call, null, loadMessage);
173
+ return;
174
+ }
152
175
  }
153
176
 
154
177
  @PluginMethod
@@ -167,13 +190,18 @@ public class CapacitorSQLitePlugin extends Plugin {
167
190
  return;
168
191
  }
169
192
  dbName = call.getString("database");
170
- try {
171
- String databasePath = implementation.getNCDatabasePath(folderPath, dbName);
172
- rHandler.retPath(call, databasePath, null);
173
- return;
174
- } catch (Exception e) {
175
- String msg = "getNCDatabasePath: " + e.getMessage();
176
- rHandler.retResult(call, null, msg);
193
+ if (implementation != null) {
194
+ try {
195
+ String databasePath = implementation.getNCDatabasePath(folderPath, dbName);
196
+ rHandler.retPath(call, databasePath, null);
197
+ return;
198
+ } catch (Exception e) {
199
+ String msg = "getNCDatabasePath: " + e.getMessage();
200
+ rHandler.retResult(call, null, msg);
201
+ return;
202
+ }
203
+ } else {
204
+ rHandler.retResult(call, null, loadMessage);
177
205
  return;
178
206
  }
179
207
  }
@@ -195,13 +223,18 @@ public class CapacitorSQLitePlugin extends Plugin {
195
223
  }
196
224
  dbPath = call.getString("databasePath");
197
225
  dbVersion = call.getInt("version", 1);
198
- try {
199
- implementation.createNCConnection(dbPath, dbVersion);
200
- rHandler.retResult(call, null, null);
201
- return;
202
- } catch (Exception e) {
203
- String msg = "CreateNCConnection: " + e.getMessage();
204
- rHandler.retResult(call, null, msg);
226
+ if (implementation != null) {
227
+ try {
228
+ implementation.createNCConnection(dbPath, dbVersion);
229
+ rHandler.retResult(call, null, null);
230
+ return;
231
+ } catch (Exception e) {
232
+ String msg = "CreateNCConnection: " + e.getMessage();
233
+ rHandler.retResult(call, null, msg);
234
+ return;
235
+ }
236
+ } else {
237
+ rHandler.retResult(call, null, loadMessage);
205
238
  return;
206
239
  }
207
240
  }
@@ -242,13 +275,18 @@ public class CapacitorSQLitePlugin extends Plugin {
242
275
  inMode = "no-encryption";
243
276
  }
244
277
  Dictionary<Integer, JSONObject> upgDict = versionUpgrades.get(dbName);
245
- try {
246
- implementation.createConnection(dbName, encrypted, inMode, dbVersion, upgDict);
247
- rHandler.retResult(call, null, null);
248
- return;
249
- } catch (Exception e) {
250
- String msg = "CreateConnection: " + e.getMessage();
251
- rHandler.retResult(call, null, msg);
278
+ if (implementation != null) {
279
+ try {
280
+ implementation.createConnection(dbName, encrypted, inMode, dbVersion, upgDict);
281
+ rHandler.retResult(call, null, null);
282
+ return;
283
+ } catch (Exception e) {
284
+ String msg = "CreateConnection: " + e.getMessage();
285
+ rHandler.retResult(call, null, msg);
286
+ return;
287
+ }
288
+ } else {
289
+ rHandler.retResult(call, null, loadMessage);
252
290
  return;
253
291
  }
254
292
  }
@@ -267,13 +305,18 @@ public class CapacitorSQLitePlugin extends Plugin {
267
305
  return;
268
306
  }
269
307
  String dbName = call.getString("database");
270
- try {
271
- implementation.open(dbName);
272
- rHandler.retResult(call, null, null);
273
- return;
274
- } catch (Exception e) {
275
- String msg = "Open: " + e.getMessage();
276
- rHandler.retResult(call, null, msg);
308
+ if (implementation != null) {
309
+ try {
310
+ implementation.open(dbName);
311
+ rHandler.retResult(call, null, null);
312
+ return;
313
+ } catch (Exception e) {
314
+ String msg = "Open: " + e.getMessage();
315
+ rHandler.retResult(call, null, msg);
316
+ return;
317
+ }
318
+ } else {
319
+ rHandler.retResult(call, null, loadMessage);
277
320
  return;
278
321
  }
279
322
  }
@@ -292,13 +335,18 @@ public class CapacitorSQLitePlugin extends Plugin {
292
335
  return;
293
336
  }
294
337
  String dbName = call.getString("database");
295
- try {
296
- implementation.close(dbName);
297
- rHandler.retResult(call, null, null);
298
- return;
299
- } catch (Exception e) {
300
- String msg = "Close: " + e.getMessage();
301
- rHandler.retResult(call, null, msg);
338
+ if (implementation != null) {
339
+ try {
340
+ implementation.close(dbName);
341
+ rHandler.retResult(call, null, null);
342
+ return;
343
+ } catch (Exception e) {
344
+ String msg = "Close: " + e.getMessage();
345
+ rHandler.retResult(call, null, msg);
346
+ return;
347
+ }
348
+ } else {
349
+ rHandler.retResult(call, null, loadMessage);
302
350
  return;
303
351
  }
304
352
  }
@@ -317,13 +365,18 @@ public class CapacitorSQLitePlugin extends Plugin {
317
365
  return;
318
366
  }
319
367
  String dbName = call.getString("database");
320
- try {
321
- String res = implementation.getUrl(dbName);
322
- rHandler.retUrl(call, res, null);
323
- return;
324
- } catch (Exception e) {
325
- String msg = "GetUrl: " + e.getMessage();
326
- rHandler.retUrl(call, null, msg);
368
+ if (implementation != null) {
369
+ try {
370
+ String res = implementation.getUrl(dbName);
371
+ rHandler.retUrl(call, res, null);
372
+ return;
373
+ } catch (Exception e) {
374
+ String msg = "GetUrl: " + e.getMessage();
375
+ rHandler.retUrl(call, null, msg);
376
+ return;
377
+ }
378
+ } else {
379
+ rHandler.retUrl(call, null, loadMessage);
327
380
  return;
328
381
  }
329
382
  }
@@ -342,13 +395,18 @@ public class CapacitorSQLitePlugin extends Plugin {
342
395
  return;
343
396
  }
344
397
  String dbName = call.getString("database");
345
- try {
346
- Integer res = implementation.getVersion(dbName);
347
- rHandler.retVersion(call, res, null);
348
- return;
349
- } catch (Exception e) {
350
- String msg = "GetVersion: " + e.getMessage();
351
- rHandler.retVersion(call, null, msg);
398
+ if (implementation != null) {
399
+ try {
400
+ Integer res = implementation.getVersion(dbName);
401
+ rHandler.retVersion(call, res, null);
402
+ return;
403
+ } catch (Exception e) {
404
+ String msg = "GetVersion: " + e.getMessage();
405
+ rHandler.retVersion(call, null, msg);
406
+ return;
407
+ }
408
+ } else {
409
+ rHandler.retVersion(call, null, loadMessage);
352
410
  return;
353
411
  }
354
412
  }
@@ -367,13 +425,18 @@ public class CapacitorSQLitePlugin extends Plugin {
367
425
  return;
368
426
  }
369
427
  String dbPath = call.getString("databasePath");
370
- try {
371
- implementation.closeNCConnection(dbPath);
372
- rHandler.retResult(call, null, null);
373
- return;
374
- } catch (Exception e) {
375
- String msg = "CloseNCConnection: " + e.getMessage();
376
- rHandler.retResult(call, null, msg);
428
+ if (implementation != null) {
429
+ try {
430
+ implementation.closeNCConnection(dbPath);
431
+ rHandler.retResult(call, null, null);
432
+ return;
433
+ } catch (Exception e) {
434
+ String msg = "CloseNCConnection: " + e.getMessage();
435
+ rHandler.retResult(call, null, msg);
436
+ return;
437
+ }
438
+ } else {
439
+ rHandler.retResult(call, null, loadMessage);
377
440
  return;
378
441
  }
379
442
  }
@@ -392,13 +455,18 @@ public class CapacitorSQLitePlugin extends Plugin {
392
455
  return;
393
456
  }
394
457
  String dbName = call.getString("database");
395
- try {
396
- implementation.closeConnection(dbName);
397
- rHandler.retResult(call, null, null);
398
- return;
399
- } catch (Exception e) {
400
- String msg = "CloseConnection: " + e.getMessage();
401
- rHandler.retResult(call, null, msg);
458
+ if (implementation != null) {
459
+ try {
460
+ implementation.closeConnection(dbName);
461
+ rHandler.retResult(call, null, null);
462
+ return;
463
+ } catch (Exception e) {
464
+ String msg = "CloseConnection: " + e.getMessage();
465
+ rHandler.retResult(call, null, msg);
466
+ return;
467
+ }
468
+ } else {
469
+ rHandler.retResult(call, null, loadMessage);
402
470
  return;
403
471
  }
404
472
  }
@@ -417,13 +485,18 @@ public class CapacitorSQLitePlugin extends Plugin {
417
485
  return;
418
486
  }
419
487
  JSArray dbNames = call.getArray("dbNames");
420
- try {
421
- Boolean res = implementation.checkConnectionsConsistency(dbNames);
422
- rHandler.retResult(call, res, null);
423
- return;
424
- } catch (Exception e) {
425
- String msg = "CheckConnectionsConsistency: " + e.getMessage();
426
- rHandler.retResult(call, null, msg);
488
+ if (implementation != null) {
489
+ try {
490
+ Boolean res = implementation.checkConnectionsConsistency(dbNames);
491
+ rHandler.retResult(call, res, null);
492
+ return;
493
+ } catch (Exception e) {
494
+ String msg = "CheckConnectionsConsistency: " + e.getMessage();
495
+ rHandler.retResult(call, null, msg);
496
+ return;
497
+ }
498
+ } else {
499
+ rHandler.retResult(call, null, loadMessage);
427
500
  return;
428
501
  }
429
502
  }
@@ -441,13 +514,18 @@ public class CapacitorSQLitePlugin extends Plugin {
441
514
  return;
442
515
  }
443
516
  String dbName = call.getString("database");
444
- try {
445
- Boolean res = implementation.isDatabase(dbName);
446
- rHandler.retResult(call, res, null);
447
- return;
448
- } catch (Exception e) {
449
- String msg = "isDatabase: " + e.getMessage();
450
- rHandler.retResult(call, null, msg);
517
+ if (implementation != null) {
518
+ try {
519
+ Boolean res = implementation.isDatabase(dbName);
520
+ rHandler.retResult(call, res, null);
521
+ return;
522
+ } catch (Exception e) {
523
+ String msg = "isDatabase: " + e.getMessage();
524
+ rHandler.retResult(call, null, msg);
525
+ return;
526
+ }
527
+ } else {
528
+ rHandler.retResult(call, null, loadMessage);
451
529
  return;
452
530
  }
453
531
  }
@@ -465,13 +543,18 @@ public class CapacitorSQLitePlugin extends Plugin {
465
543
  return;
466
544
  }
467
545
  String dbPath = call.getString("databasePath");
468
- try {
469
- Boolean res = implementation.isNCDatabase(dbPath);
470
- rHandler.retResult(call, res, null);
471
- return;
472
- } catch (Exception e) {
473
- String msg = "isNCDatabase: " + e.getMessage();
474
- rHandler.retResult(call, null, msg);
546
+ if (implementation != null) {
547
+ try {
548
+ Boolean res = implementation.isNCDatabase(dbPath);
549
+ rHandler.retResult(call, res, null);
550
+ return;
551
+ } catch (Exception e) {
552
+ String msg = "isNCDatabase: " + e.getMessage();
553
+ rHandler.retResult(call, null, msg);
554
+ return;
555
+ }
556
+ } else {
557
+ rHandler.retResult(call, null, loadMessage);
475
558
  return;
476
559
  }
477
560
  }
@@ -494,13 +577,18 @@ public class CapacitorSQLitePlugin extends Plugin {
494
577
  return;
495
578
  }
496
579
  String tableName = call.getString("table");
497
- try {
498
- Boolean res = implementation.isTableExists(dbName, tableName);
499
- rHandler.retResult(call, res, null);
500
- return;
501
- } catch (Exception e) {
502
- String msg = "isTableExists: " + e.getMessage();
503
- rHandler.retResult(call, null, msg);
580
+ if (implementation != null) {
581
+ try {
582
+ Boolean res = implementation.isTableExists(dbName, tableName);
583
+ rHandler.retResult(call, res, null);
584
+ return;
585
+ } catch (Exception e) {
586
+ String msg = "isTableExists: " + e.getMessage();
587
+ rHandler.retResult(call, null, msg);
588
+ return;
589
+ }
590
+ } else {
591
+ rHandler.retResult(call, null, loadMessage);
504
592
  return;
505
593
  }
506
594
  }
@@ -511,13 +599,18 @@ public class CapacitorSQLitePlugin extends Plugin {
511
599
  */
512
600
  @PluginMethod
513
601
  public void getDatabaseList(PluginCall call) {
514
- try {
515
- JSArray res = implementation.getDatabaseList();
516
- rHandler.retValues(call, res, null);
517
- return;
518
- } catch (Exception e) {
519
- String msg = "getDatabaseList: " + e.getMessage();
520
- rHandler.retValues(call, new JSArray(), msg);
602
+ if (implementation != null) {
603
+ try {
604
+ JSArray res = implementation.getDatabaseList();
605
+ rHandler.retValues(call, res, null);
606
+ return;
607
+ } catch (Exception e) {
608
+ String msg = "getDatabaseList: " + e.getMessage();
609
+ rHandler.retValues(call, new JSArray(), msg);
610
+ return;
611
+ }
612
+ } else {
613
+ rHandler.retValues(call, new JSArray(), loadMessage);
521
614
  return;
522
615
  }
523
616
  }
@@ -535,13 +628,18 @@ public class CapacitorSQLitePlugin extends Plugin {
535
628
  } else {
536
629
  folderPath = call.getString("folderPath");
537
630
  }
538
- try {
539
- JSArray res = implementation.getMigratableDbList(folderPath);
540
- rHandler.retValues(call, res, null);
541
- return;
542
- } catch (Exception e) {
543
- String msg = "getMigratableDbList: " + e.getMessage();
544
- rHandler.retValues(call, new JSArray(), msg);
631
+ if (implementation != null) {
632
+ try {
633
+ JSArray res = implementation.getMigratableDbList(folderPath);
634
+ rHandler.retValues(call, res, null);
635
+ return;
636
+ } catch (Exception e) {
637
+ String msg = "getMigratableDbList: " + e.getMessage();
638
+ rHandler.retValues(call, new JSArray(), msg);
639
+ return;
640
+ }
641
+ } else {
642
+ rHandler.retValues(call, new JSArray(), loadMessage);
545
643
  return;
546
644
  }
547
645
  }
@@ -564,13 +662,18 @@ public class CapacitorSQLitePlugin extends Plugin {
564
662
  } else {
565
663
  dbList = call.getArray("dbNameList");
566
664
  }
567
- try {
568
- implementation.addSQLiteSuffix(folderPath, dbList);
569
- rHandler.retResult(call, null, null);
570
- return;
571
- } catch (Exception e) {
572
- String msg = "addSQLiteSuffix: " + e.getMessage();
573
- rHandler.retResult(call, null, msg);
665
+ if (implementation != null) {
666
+ try {
667
+ implementation.addSQLiteSuffix(folderPath, dbList);
668
+ rHandler.retResult(call, null, null);
669
+ return;
670
+ } catch (Exception e) {
671
+ String msg = "addSQLiteSuffix: " + e.getMessage();
672
+ rHandler.retResult(call, null, msg);
673
+ return;
674
+ }
675
+ } else {
676
+ rHandler.retResult(call, null, loadMessage);
574
677
  return;
575
678
  }
576
679
  }
@@ -593,13 +696,18 @@ public class CapacitorSQLitePlugin extends Plugin {
593
696
  } else {
594
697
  dbList = call.getArray("dbNameList");
595
698
  }
596
- try {
597
- implementation.deleteOldDatabases(folderPath, dbList);
598
- rHandler.retResult(call, null, null);
599
- return;
600
- } catch (Exception e) {
601
- String msg = "deleteOldDatabases: " + e.getMessage();
602
- rHandler.retResult(call, null, msg);
699
+ if (implementation != null) {
700
+ try {
701
+ implementation.deleteOldDatabases(folderPath, dbList);
702
+ rHandler.retResult(call, null, null);
703
+ return;
704
+ } catch (Exception e) {
705
+ String msg = "deleteOldDatabases: " + e.getMessage();
706
+ rHandler.retResult(call, null, msg);
707
+ return;
708
+ }
709
+ } else {
710
+ rHandler.retResult(call, null, loadMessage);
603
711
  return;
604
712
  }
605
713
  }
@@ -628,13 +736,18 @@ public class CapacitorSQLitePlugin extends Plugin {
628
736
  String statements = call.getString("statements");
629
737
  Boolean transaction = call.getBoolean("transaction", true);
630
738
 
631
- try {
632
- JSObject res = implementation.execute(dbName, statements, transaction);
633
- rHandler.retChanges(call, res, null);
634
- return;
635
- } catch (Exception e) {
636
- String msg = "Execute: " + e.getMessage();
637
- rHandler.retChanges(call, retRes, msg);
739
+ if (implementation != null) {
740
+ try {
741
+ JSObject res = implementation.execute(dbName, statements, transaction);
742
+ rHandler.retChanges(call, res, null);
743
+ return;
744
+ } catch (Exception e) {
745
+ String msg = "Execute: " + e.getMessage();
746
+ rHandler.retChanges(call, retRes, msg);
747
+ return;
748
+ }
749
+ } else {
750
+ rHandler.retChanges(call, retRes, loadMessage);
638
751
  return;
639
752
  }
640
753
  }
@@ -680,13 +793,18 @@ public class CapacitorSQLitePlugin extends Plugin {
680
793
  }
681
794
  }
682
795
  Boolean transaction = call.getBoolean("transaction", true);
683
- try {
684
- JSObject res = implementation.executeSet(dbName, set, transaction);
685
- rHandler.retChanges(call, res, null);
686
- return;
687
- } catch (Exception e) {
688
- String msg = "ExecuteSet: " + e.getMessage();
689
- rHandler.retChanges(call, retRes, msg);
796
+ if (implementation != null) {
797
+ try {
798
+ JSObject res = implementation.executeSet(dbName, set, transaction);
799
+ rHandler.retChanges(call, res, null);
800
+ return;
801
+ } catch (Exception e) {
802
+ String msg = "ExecuteSet: " + e.getMessage();
803
+ rHandler.retChanges(call, retRes, msg);
804
+ return;
805
+ }
806
+ } else {
807
+ rHandler.retChanges(call, retRes, loadMessage);
690
808
  return;
691
809
  }
692
810
  }
@@ -721,14 +839,18 @@ public class CapacitorSQLitePlugin extends Plugin {
721
839
  JSArray values = call.getArray("values");
722
840
 
723
841
  Boolean transaction = call.getBoolean("transaction", true);
724
-
725
- try {
726
- JSObject res = implementation.run(dbName, statement, values, transaction);
727
- rHandler.retChanges(call, res, null);
728
- return;
729
- } catch (Exception e) {
730
- String msg = "Run: " + e.getMessage();
731
- rHandler.retChanges(call, retRes, msg);
842
+ if (implementation != null) {
843
+ try {
844
+ JSObject res = implementation.run(dbName, statement, values, transaction);
845
+ rHandler.retChanges(call, res, null);
846
+ return;
847
+ } catch (Exception e) {
848
+ String msg = "Run: " + e.getMessage();
849
+ rHandler.retChanges(call, retRes, msg);
850
+ return;
851
+ }
852
+ } else {
853
+ rHandler.retChanges(call, retRes, loadMessage);
732
854
  return;
733
855
  }
734
856
  }
@@ -759,13 +881,18 @@ public class CapacitorSQLitePlugin extends Plugin {
759
881
  return;
760
882
  }
761
883
  JSArray values = call.getArray("values");
762
- try {
763
- JSArray res = implementation.query(dbName, statement, values);
764
- rHandler.retValues(call, res, null);
765
- return;
766
- } catch (Exception e) {
767
- String msg = "Query: " + e.getMessage();
768
- rHandler.retValues(call, new JSArray(), msg);
884
+ if (implementation != null) {
885
+ try {
886
+ JSArray res = implementation.query(dbName, statement, values);
887
+ rHandler.retValues(call, res, null);
888
+ return;
889
+ } catch (Exception e) {
890
+ String msg = "Query: " + e.getMessage();
891
+ rHandler.retValues(call, new JSArray(), msg);
892
+ return;
893
+ }
894
+ } else {
895
+ rHandler.retValues(call, new JSArray(), loadMessage);
769
896
  return;
770
897
  }
771
898
  }
@@ -785,13 +912,18 @@ public class CapacitorSQLitePlugin extends Plugin {
785
912
  }
786
913
  String dbName = call.getString("database");
787
914
 
788
- try {
789
- Boolean res = implementation.isDBExists(dbName);
790
- rHandler.retResult(call, res, null);
791
- return;
792
- } catch (Exception e) {
793
- String msg = "isDBExists: " + e.getMessage();
794
- rHandler.retResult(call, false, msg);
915
+ if (implementation != null) {
916
+ try {
917
+ Boolean res = implementation.isDBExists(dbName);
918
+ rHandler.retResult(call, res, null);
919
+ return;
920
+ } catch (Exception e) {
921
+ String msg = "isDBExists: " + e.getMessage();
922
+ rHandler.retResult(call, false, msg);
923
+ return;
924
+ }
925
+ } else {
926
+ rHandler.retResult(call, null, loadMessage);
795
927
  return;
796
928
  }
797
929
  }
@@ -810,13 +942,18 @@ public class CapacitorSQLitePlugin extends Plugin {
810
942
  return;
811
943
  }
812
944
  String dbName = call.getString("database");
813
- try {
814
- Boolean res = implementation.isDBOpen(dbName);
815
- rHandler.retResult(call, res, null);
816
- return;
817
- } catch (Exception e) {
818
- String msg = "isDBOpen: " + e.getMessage();
819
- rHandler.retResult(call, false, msg);
945
+ if (implementation != null) {
946
+ try {
947
+ Boolean res = implementation.isDBOpen(dbName);
948
+ rHandler.retResult(call, res, null);
949
+ return;
950
+ } catch (Exception e) {
951
+ String msg = "isDBOpen: " + e.getMessage();
952
+ rHandler.retResult(call, false, msg);
953
+ return;
954
+ }
955
+ } else {
956
+ rHandler.retResult(call, null, loadMessage);
820
957
  return;
821
958
  }
822
959
  }
@@ -835,13 +972,18 @@ public class CapacitorSQLitePlugin extends Plugin {
835
972
  return;
836
973
  }
837
974
  String dbName = call.getString("database");
838
- try {
839
- implementation.deleteDatabase(dbName);
840
- rHandler.retResult(call, null, null);
841
- return;
842
- } catch (Exception e) {
843
- String msg = "deleteDatabase: " + e.getMessage();
844
- rHandler.retResult(call, null, msg);
975
+ if (implementation != null) {
976
+ try {
977
+ implementation.deleteDatabase(dbName);
978
+ rHandler.retResult(call, null, null);
979
+ return;
980
+ } catch (Exception e) {
981
+ String msg = "deleteDatabase: " + e.getMessage();
982
+ rHandler.retResult(call, null, msg);
983
+ return;
984
+ }
985
+ } else {
986
+ rHandler.retResult(call, null, loadMessage);
845
987
  return;
846
988
  }
847
989
  }
@@ -862,13 +1004,18 @@ public class CapacitorSQLitePlugin extends Plugin {
862
1004
  return;
863
1005
  }
864
1006
  String dbName = call.getString("database");
865
- try {
866
- JSObject res = implementation.createSyncTable(dbName);
867
- rHandler.retChanges(call, res, null);
868
- return;
869
- } catch (Exception e) {
870
- String msg = "CreateSyncTable: " + e.getMessage();
871
- rHandler.retChanges(call, retRes, msg);
1007
+ if (implementation != null) {
1008
+ try {
1009
+ JSObject res = implementation.createSyncTable(dbName);
1010
+ rHandler.retChanges(call, res, null);
1011
+ return;
1012
+ } catch (Exception e) {
1013
+ String msg = "CreateSyncTable: " + e.getMessage();
1014
+ rHandler.retChanges(call, retRes, msg);
1015
+ return;
1016
+ }
1017
+ } else {
1018
+ rHandler.retChanges(call, retRes, loadMessage);
872
1019
  return;
873
1020
  }
874
1021
  }
@@ -894,13 +1041,18 @@ public class CapacitorSQLitePlugin extends Plugin {
894
1041
  return;
895
1042
  }
896
1043
  String syncDate = call.getString("syncdate");
897
- try {
898
- implementation.setSyncDate(dbName, syncDate);
899
- rHandler.retResult(call, null, null);
900
- return;
901
- } catch (Exception e) {
902
- String msg = "SetSyncDate: " + e.getMessage();
903
- rHandler.retResult(call, null, msg);
1044
+ if (implementation != null) {
1045
+ try {
1046
+ implementation.setSyncDate(dbName, syncDate);
1047
+ rHandler.retResult(call, null, null);
1048
+ return;
1049
+ } catch (Exception e) {
1050
+ String msg = "SetSyncDate: " + e.getMessage();
1051
+ rHandler.retResult(call, null, msg);
1052
+ return;
1053
+ }
1054
+ } else {
1055
+ rHandler.retResult(call, null, loadMessage);
904
1056
  return;
905
1057
  }
906
1058
  }
@@ -921,13 +1073,18 @@ public class CapacitorSQLitePlugin extends Plugin {
921
1073
  return;
922
1074
  }
923
1075
  String dbName = call.getString("database");
924
- try {
925
- long syncDate = implementation.getSyncDate(dbName);
926
- rHandler.retSyncDate(call, syncDate, null);
927
- return;
928
- } catch (Exception e) {
929
- String msg = "GetSyncDate: " + e.getMessage();
930
- rHandler.retSyncDate(call, new Long(0), msg);
1076
+ if (implementation != null) {
1077
+ try {
1078
+ long syncDate = implementation.getSyncDate(dbName);
1079
+ rHandler.retSyncDate(call, syncDate, null);
1080
+ return;
1081
+ } catch (Exception e) {
1082
+ String msg = "GetSyncDate: " + e.getMessage();
1083
+ rHandler.retSyncDate(call, new Long(0), msg);
1084
+ return;
1085
+ }
1086
+ } else {
1087
+ rHandler.retSyncDate(call, new Long(0), loadMessage);
931
1088
  return;
932
1089
  }
933
1090
  }
@@ -953,14 +1110,19 @@ public class CapacitorSQLitePlugin extends Plugin {
953
1110
  }
954
1111
  JSArray upgrade = call.getArray("upgrade");
955
1112
 
956
- try {
957
- Dictionary<Integer, JSONObject> upgDict = implementation.addUpgradeStatement(upgrade);
958
- versionUpgrades.put(dbName, upgDict);
959
- rHandler.retResult(call, null, null);
960
- return;
961
- } catch (Exception e) {
962
- String msg = "AddUpgradeStatement: " + e.getMessage();
963
- rHandler.retResult(call, null, msg);
1113
+ if (implementation != null) {
1114
+ try {
1115
+ Dictionary<Integer, JSONObject> upgDict = implementation.addUpgradeStatement(upgrade);
1116
+ versionUpgrades.put(dbName, upgDict);
1117
+ rHandler.retResult(call, null, null);
1118
+ return;
1119
+ } catch (Exception e) {
1120
+ String msg = "AddUpgradeStatement: " + e.getMessage();
1121
+ rHandler.retResult(call, null, msg);
1122
+ return;
1123
+ }
1124
+ } else {
1125
+ rHandler.retResult(call, null, loadMessage);
964
1126
  return;
965
1127
  }
966
1128
  }
@@ -979,13 +1141,18 @@ public class CapacitorSQLitePlugin extends Plugin {
979
1141
  return;
980
1142
  }
981
1143
  String parsingData = call.getString("jsonstring");
982
- try {
983
- Boolean res = implementation.isJsonValid(parsingData);
984
- rHandler.retResult(call, res, null);
985
- return;
986
- } catch (Exception e) {
987
- String msg = "IsJsonValid: " + e.getMessage();
988
- rHandler.retResult(call, false, msg);
1144
+ if (implementation != null) {
1145
+ try {
1146
+ Boolean res = implementation.isJsonValid(parsingData);
1147
+ rHandler.retResult(call, res, null);
1148
+ return;
1149
+ } catch (Exception e) {
1150
+ String msg = "IsJsonValid: " + e.getMessage();
1151
+ rHandler.retResult(call, false, msg);
1152
+ return;
1153
+ }
1154
+ } else {
1155
+ rHandler.retResult(call, null, loadMessage);
989
1156
  return;
990
1157
  }
991
1158
  }
@@ -1006,13 +1173,18 @@ public class CapacitorSQLitePlugin extends Plugin {
1006
1173
  return;
1007
1174
  }
1008
1175
  String parsingData = call.getString("jsonstring");
1009
- try {
1010
- JSObject res = implementation.importFromJson(parsingData);
1011
- rHandler.retChanges(call, res, null);
1012
- return;
1013
- } catch (Exception e) {
1014
- String msg = "ImportFromJson: " + e.getMessage();
1015
- rHandler.retChanges(call, retRes, msg);
1176
+ if (implementation != null) {
1177
+ try {
1178
+ JSObject res = implementation.importFromJson(parsingData);
1179
+ rHandler.retChanges(call, res, null);
1180
+ return;
1181
+ } catch (Exception e) {
1182
+ String msg = "ImportFromJson: " + e.getMessage();
1183
+ rHandler.retChanges(call, retRes, msg);
1184
+ return;
1185
+ }
1186
+ } else {
1187
+ rHandler.retChanges(call, retRes, loadMessage);
1016
1188
  return;
1017
1189
  }
1018
1190
  }
@@ -1046,13 +1218,18 @@ public class CapacitorSQLitePlugin extends Plugin {
1046
1218
  return;
1047
1219
  }
1048
1220
 
1049
- try {
1050
- JSObject res = implementation.exportToJson(dbName, expMode);
1051
- rHandler.retJSObject(call, res, null);
1052
- return;
1053
- } catch (Exception e) {
1054
- String msg = "ExportToJson: " + e.getMessage();
1055
- rHandler.retJSObject(call, retObj, msg);
1221
+ if (implementation != null) {
1222
+ try {
1223
+ JSObject res = implementation.exportToJson(dbName, expMode);
1224
+ rHandler.retJSObject(call, res, null);
1225
+ return;
1226
+ } catch (Exception e) {
1227
+ String msg = "ExportToJson: " + e.getMessage();
1228
+ rHandler.retJSObject(call, retObj, msg);
1229
+ return;
1230
+ }
1231
+ } else {
1232
+ rHandler.retJSObject(call, retObj, loadMessage);
1056
1233
  return;
1057
1234
  }
1058
1235
  }
@@ -1067,13 +1244,18 @@ public class CapacitorSQLitePlugin extends Plugin {
1067
1244
  public void copyFromAssets(PluginCall call) {
1068
1245
  Boolean overwrite = call.getData().has("overwrite") ? call.getBoolean("overwrite") : true;
1069
1246
 
1070
- try {
1071
- implementation.copyFromAssets(overwrite);
1072
- rHandler.retResult(call, null, null);
1073
- return;
1074
- } catch (Exception e) {
1075
- String msg = "CopyFromAssets: " + e.getMessage();
1076
- rHandler.retResult(call, null, msg);
1247
+ if (implementation != null) {
1248
+ try {
1249
+ implementation.copyFromAssets(overwrite);
1250
+ rHandler.retResult(call, null, null);
1251
+ return;
1252
+ } catch (Exception e) {
1253
+ String msg = "CopyFromAssets: " + e.getMessage();
1254
+ rHandler.retResult(call, null, msg);
1255
+ return;
1256
+ }
1257
+ } else {
1258
+ rHandler.retResult(call, null, loadMessage);
1077
1259
  return;
1078
1260
  }
1079
1261
  }
@@ -1126,9 +1308,12 @@ public class CapacitorSQLitePlugin extends Plugin {
1126
1308
 
1127
1309
  private SqliteConfig getSqliteConfig() throws JSONException {
1128
1310
  SqliteConfig config = new SqliteConfig();
1129
- JSONObject androidBiometric = getConfig().getObject("androidBiometric");
1311
+ JSONObject pConfig = getConfig().getConfigJSON();
1312
+ Boolean isEncryption = pConfig.has("androidIsEncryption") ? pConfig.getBoolean("androidIsEncryption") : config.getIsEncryption();
1313
+ config.setIsEncryption(isEncryption);
1314
+ JSONObject androidBiometric = pConfig.has("androidBiometric") ? pConfig.getJSONObject("androidBiometric") : null;
1130
1315
  if (androidBiometric != null) {
1131
- Boolean biometricAuth = androidBiometric.has("biometricAuth")
1316
+ Boolean biometricAuth = androidBiometric.has("biometricAuth") && isEncryption
1132
1317
  ? androidBiometric.getBoolean("biometricAuth")
1133
1318
  : config.getBiometricAuth();
1134
1319
  config.setBiometricAuth(biometricAuth);