@capacitor-community/sqlite 3.3.2 → 3.3.3-4

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 (37) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +28 -2
  3. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +105 -7
  4. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +126 -4
  5. package/android/src/main/java/com/getcapacitor/community/database/sqlite/RetHandler.java +48 -0
  6. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +75 -47
  7. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/JsonIndex.java +5 -4
  8. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsFile.java +9 -0
  9. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsNCDatabase.java +26 -0
  10. package/dist/esm/definitions.d.ts +131 -2
  11. package/dist/esm/definitions.js +74 -0
  12. package/dist/esm/definitions.js.map +1 -1
  13. package/dist/esm/web.d.ts +6 -1
  14. package/dist/esm/web.js +19 -0
  15. package/dist/esm/web.js.map +1 -1
  16. package/dist/plugin.cjs.js +93 -0
  17. package/dist/plugin.cjs.js.map +1 -1
  18. package/dist/plugin.js +93 -0
  19. package/dist/plugin.js.map +1 -1
  20. package/electron/dist/plugin.js +20 -1
  21. package/electron/dist/plugin.js.map +1 -1
  22. package/ios/Plugin/CapacitorSQLite.swift +139 -20
  23. package/ios/Plugin/CapacitorSQLitePlugin.m +5 -0
  24. package/ios/Plugin/CapacitorSQLitePlugin.swift +269 -64
  25. package/ios/Plugin/Database.swift +63 -28
  26. package/ios/Plugin/ImportExportJson/ImportFromJson.swift +2 -1
  27. package/ios/Plugin/ImportExportJson/JsonSQLite.swift +1 -1
  28. package/ios/Plugin/ReturnHandler.swift +25 -0
  29. package/ios/Plugin/SqliteConfig.swift +10 -0
  30. package/ios/Plugin/Utils/UtilsEncryption.swift +10 -7
  31. package/ios/Plugin/Utils/UtilsFile.swift +195 -33
  32. package/ios/Plugin/Utils/UtilsMigrate.swift +11 -44
  33. package/ios/Plugin/Utils/UtilsNCDatabase.swift +31 -0
  34. package/ios/Plugin/Utils/UtilsSQLCipher.swift +29 -24
  35. package/ios/Plugin/Utils/UtilsSecret.swift +22 -8
  36. package/ios/Plugin/Utils/UtilsUpgrade.swift +6 -2
  37. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,3 +1,50 @@
1
+ ## 3.3.3-4 (2022-01-06)
2
+
3
+ ### Added Features
4
+
5
+ - add getUrl method Get DB Path iOS & Android
6
+
7
+ ### Bug Fixes
8
+
9
+ - fix Get DB Path or file URI issue#208
10
+
11
+ ## 3.3.3-3 (2022-01-03)
12
+
13
+ ### Bug Fixes
14
+
15
+ - fix Android Error during database version upgrade issue#209
16
+
17
+ ## 3.3.3-2 (2022-01-03)
18
+
19
+ ### Added Features
20
+
21
+ - iOS Support for databases that are not visible to iTunes and are not backed up by iCloud issue#207
22
+
23
+ ### Bug Fixes
24
+
25
+ - fix README.md
26
+ - fix API.md
27
+
28
+ ## 3.3.3-1 (2021-12-18)
29
+
30
+ ### Chore
31
+
32
+ - Update to @capacitor/core 3.3.3
33
+ - Update to @capacitor/ios 3.3.3
34
+ - Update to @capacitor/android 3.3.3
35
+
36
+ ### Added Features
37
+
38
+ - Open in Read-Only Mode databases without SQLite suffix
39
+ - getNCDatabasePath, createNCConnection, closeNCConnection, isNCDatabase
40
+ - add NonConformedDatabase.md documentation
41
+
42
+ ### Bug Fixes
43
+
44
+ - fix mode "UNIQUE" not case sensitive in importToJson index issue#203
45
+ - fix support non-conformed database in read-only mode issue#201
46
+
47
+
1
48
  ## 3.3.2 (2021-12-13)
2
49
 
3
50
  ### Chore
package/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  <a href="https://www.npmjs.com/package/@capacitor-community/sqlite"><img src="https://img.shields.io/npm/dw/@capacitor-community/sqlite?style=flat-square" /></a>
17
17
  <a href="https://www.npmjs.com/package/@capacitor-community/sqlite"><img src="https://img.shields.io/npm/v/@capacitor-community/sqlite?style=flat-square" /></a>
18
18
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
19
- <a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-9-orange?style=flat-square" /></a>
19
+ <a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-11-orange?style=flat-square" /></a>
20
20
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
21
21
  </p>
22
22
 
@@ -28,6 +28,23 @@
28
28
 
29
29
  ## CAPACITOR 3 (Master)
30
30
 
31
+ 🚨 Since release 3.3.3-2 ->> 🚨
32
+
33
+ - iOS only
34
+ Support for a database location not visible to iTunes and backed up to iCloud.
35
+ For this you must add to the `const config: CapacitorConfig` of the `capacitor.config.ts` file of your application the following:
36
+ ```ts
37
+ plugins: {
38
+ CapacitorSQLite: {
39
+ "iosDatabaseLocation": "Library/CapacitorDatabase"
40
+ }
41
+ }
42
+ ```
43
+ Pre-existing databases from the `Documents` folder will be moved to the new folder `Library/CapacitorDatabase` and your application will work as before.
44
+ If you do not modify the `capacitor.config.ts` file of your application the databases will still reside in the `Documents` folder
45
+
46
+ 🚨 Since release 3.3.3-2 <<- 🚨
47
+
31
48
  🚨 Since release 3.2.5-2 ->> 🚨
32
49
 
33
50
  - support zip file in copyFromAssets method
@@ -184,6 +201,7 @@ No configuration required for this plugin
184
201
  | open (non-encrypted DB) | ✅ | ✅ | ✅ | ✅ |
185
202
  | open (encrypted DB) | ✅ | ✅ | ❌ | ❌ |
186
203
  | close | ✅ | ✅ | ✅ | ✅ |
204
+ | getUrl | ✅ | ✅ | ❌ | ❌ |
187
205
  | getVersion | ✅ | ✅ | ✅ | ✅ |
188
206
  | execute | ✅ | ✅ | ✅ | ✅ |
189
207
  | executeSet | ✅ | ✅ | ✅ | ✅ |
@@ -212,6 +230,10 @@ No configuration required for this plugin
212
230
  | changeEncryptionSecret | ✅ | ✅ | ❌ | ❌ |
213
231
  | initWebStore | ❌ | ❌ | ❌ | ✅ |
214
232
  | saveToStore | ❌ | ❌ | ❌ | ✅ |
233
+ | getNCDatabasePath | ✅ | ✅ | ❌ | ❌ |
234
+ | createNCConnection | ✅ | ✅ | ❌ | ❌ |
235
+ | closeNCConnection | ✅ | ✅ | ❌ | ❌ |
236
+ | isNCDatabase | ✅ | ✅ | ❌ | ❌ |
215
237
 
216
238
  ## Supported SQLite Types
217
239
 
@@ -237,6 +259,8 @@ No configuration required for this plugin
237
259
 
238
260
  - [Web_Documentation](https://github.com/capacitor-community/sqlite/blob/master/docs/Web-Usage.md)
239
261
 
262
+ - [Non_Conformed_Databases_Documentation](https://github.com/capacitor-community/sqlite/blob/master/docs/NonConformedDatabases.md)
263
+
240
264
  ### Framework's Usage
241
265
 
242
266
  - [Ionic/Angular_Usage_Documentation](https://github.com/capacitor-community/sqlite/blob/master/docs/Ionic-Angular-Usage.md)
@@ -302,7 +326,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
302
326
  <td align="center"><a href="https://github.com/digaus"><img src="https://avatars.githubusercontent.com/u/15358538?v=4" width="100px;" alt=""/><br /><sub><b>Dirk Gausmann</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td>
303
327
  <td align="center"><a href="https://github.com/IT-MikeS"><img src="https://avatars.githubusercontent.com/u/20338451?v=4" width="100px;" alt=""/><br /><sub><b>Mike Summerfeldt</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td>
304
328
  <td align="center"><a href="https://github.com/peakcool"><img src="https://avatars.githubusercontent.com/u/14804014?v=4" width="100px;" alt=""/><br /><sub><b>Peakcool</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td>
305
- <td align="center"><a href="https://github.com/gion-andri"><img src="https://avatars.githubusercontent.com/u/540998?v=4" width="100px;" alt=""/><br /><sub><b>Gion-Andri Cantieni</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Documentation">💻</a></td>
329
+ <td align="center"><a href="https://github.com/gion-andri"><img src="https://avatars.githubusercontent.com/u/540998?v=4" width="100px;" alt=""/><br /><sub><b>Gion-Andri Cantieni</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Documentation">📖</a></td>
330
+ <td align="center"><a href="https://github.com/robingenz"><img src="https://avatars.githubusercontent.com/u/13857929?v=4" width="100px;" alt=""/><br /><sub><b>Robin Genz</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Documentation">📖</a></td>
331
+ <td align="center"><a href="https://github.com/dewald-els"><img src="https://avatars.githubusercontent.com/u/10051247?v=4" width="100px;" alt=""/><br /><sub><b>Dewald Els</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td>
306
332
  </tr>
307
333
  </table>
308
334
 
@@ -14,6 +14,7 @@ import com.getcapacitor.community.database.sqlite.SQLite.ImportExportJson.JsonSQ
14
14
  import com.getcapacitor.community.database.sqlite.SQLite.ImportExportJson.UtilsJson;
15
15
  import com.getcapacitor.community.database.sqlite.SQLite.UtilsFile;
16
16
  import com.getcapacitor.community.database.sqlite.SQLite.UtilsMigrate;
17
+ import com.getcapacitor.community.database.sqlite.SQLite.UtilsNCDatabase;
17
18
  import com.getcapacitor.community.database.sqlite.SQLite.UtilsSQLite;
18
19
  import com.getcapacitor.community.database.sqlite.SQLite.UtilsSecret;
19
20
  import java.io.File;
@@ -39,6 +40,7 @@ public class CapacitorSQLite {
39
40
  private UtilsFile uFile = new UtilsFile();
40
41
  private UtilsJson uJson = new UtilsJson();
41
42
  private UtilsMigrate uMigrate = new UtilsMigrate();
43
+ private UtilsNCDatabase uNCDatabase = new UtilsNCDatabase();
42
44
  private UtilsSecret uSecret;
43
45
  private SharedPreferences sharedPreferences;
44
46
 
@@ -116,6 +118,15 @@ public class CapacitorSQLite {
116
118
  }
117
119
  }
118
120
 
121
+ public String getNCDatabasePath(String folderPath, String database) throws Exception {
122
+ try {
123
+ String databasePath = uNCDatabase.getNCDatabasePath(context, folderPath, database);
124
+ return databasePath;
125
+ } catch (Exception e) {
126
+ throw new Exception(e.getMessage());
127
+ }
128
+ }
129
+
119
130
  /**
120
131
  * CreateConnection
121
132
  * @param dbName
@@ -148,6 +159,38 @@ public class CapacitorSQLite {
148
159
  }
149
160
  }
150
161
 
162
+ /**
163
+ * CreateConnection
164
+ * @param dbPath
165
+ * @param version
166
+ * @throws Exception
167
+ */
168
+ public void createNCConnection(String dbPath, int version) throws Exception {
169
+ // check if connection already exists
170
+ Database conn = dbDict.get(dbPath);
171
+ if (conn != null) {
172
+ String msg = "Connection " + dbPath + " already exists";
173
+ throw new Exception(msg);
174
+ }
175
+ try {
176
+ Boolean isDBPathExists = uFile.isPathExists(dbPath);
177
+ if (!isDBPathExists) {
178
+ String msg = "Database " + dbPath + " does not exist";
179
+ throw new Exception(msg);
180
+ }
181
+ Database db = new Database(context, dbPath, false, "no-encryption", version, new Hashtable<>(), sharedPreferences);
182
+ if (db != null) {
183
+ dbDict.put(dbPath, db);
184
+ return;
185
+ } else {
186
+ String msg = "db is null";
187
+ throw new Exception(msg);
188
+ }
189
+ } catch (Exception e) {
190
+ throw new Exception(e.getMessage());
191
+ }
192
+ }
193
+
151
194
  /**
152
195
  * Open
153
196
  * @param dbName
@@ -200,6 +243,28 @@ public class CapacitorSQLite {
200
243
  }
201
244
  }
202
245
 
246
+ /**
247
+ * GetUrl
248
+ * @param dbName
249
+ * @throws Exception
250
+ * @return String
251
+ */
252
+ public String getUrl(String dbName) throws Exception {
253
+ dbName = getDatabaseName(dbName);
254
+ Database db = dbDict.get(dbName);
255
+ if (db != null) {
256
+ try {
257
+ String url = db.getUrl();
258
+ return url;
259
+ } catch (Exception e) {
260
+ throw new Exception(e.getMessage());
261
+ }
262
+ } else {
263
+ String msg = "No available connection for database " + dbName;
264
+ throw new Exception(msg);
265
+ }
266
+ }
267
+
203
268
  /**
204
269
  * GetVersion
205
270
  * @param dbName
@@ -222,6 +287,29 @@ public class CapacitorSQLite {
222
287
  }
223
288
  }
224
289
 
290
+ /**
291
+ * CloseNCConnection
292
+ * @param dbPath
293
+ * @throws Exception
294
+ */
295
+ public void closeNCConnection(String dbPath) throws Exception {
296
+ Database db = dbDict.get(dbPath);
297
+ if (db != null) {
298
+ if (db.isOpen()) {
299
+ try {
300
+ close(dbPath);
301
+ } catch (Exception e) {
302
+ throw new Exception(e.getMessage());
303
+ }
304
+ }
305
+ dbDict.remove(dbPath);
306
+ return;
307
+ } else {
308
+ String msg = "No available connection for database " + dbPath;
309
+ throw new Exception(msg);
310
+ }
311
+ }
312
+
225
313
  /**
226
314
  * CloseConnection
227
315
  * @param dbName
@@ -301,6 +389,16 @@ public class CapacitorSQLite {
301
389
  return uFile.isFileExists(context, dbName + "SQLite.db");
302
390
  }
303
391
 
392
+ /**
393
+ * IsNCDatabase
394
+ * @param dbPath
395
+ * @return Boolean
396
+ * @throws Exception
397
+ */
398
+ public Boolean isNCDatabase(String dbPath) {
399
+ return uFile.isPathExists(dbPath);
400
+ }
401
+
304
402
  /**
305
403
  * IsTableExists
306
404
  * @param dbName
@@ -398,7 +496,7 @@ public class CapacitorSQLite {
398
496
  dbName = getDatabaseName(dbName);
399
497
  Database db = dbDict.get(dbName);
400
498
  if (db != null) {
401
- if (db.isOpen()) {
499
+ if (!db.isNCDB() && db.isOpen()) {
402
500
  // convert string in string[]
403
501
  String[] sqlCmdArray = uSqlite.getStatementsArray(statements);
404
502
  try {
@@ -428,7 +526,7 @@ public class CapacitorSQLite {
428
526
  dbName = getDatabaseName(dbName);
429
527
  Database db = dbDict.get(dbName);
430
528
  if (db != null) {
431
- if (db.isOpen()) {
529
+ if (!db.isNCDB() && db.isOpen()) {
432
530
  try {
433
531
  JSObject res = db.executeSet(set, transaction);
434
532
  return res;
@@ -458,7 +556,7 @@ public class CapacitorSQLite {
458
556
  dbName = getDatabaseName(dbName);
459
557
  Database db = dbDict.get(dbName);
460
558
  if (db != null) {
461
- if (db.isOpen()) {
559
+ if (!db.isNCDB() && db.isOpen()) {
462
560
  if (values.length() > 0) {
463
561
  try {
464
562
  ArrayList<Object> arrValues = uSqlite.objectJSArrayToArrayList(values);
@@ -737,11 +835,11 @@ public class CapacitorSQLite {
737
835
 
738
836
  private String getDatabaseName(String dbName) {
739
837
  String retName = dbName;
740
-
741
- if (retName.endsWith(".db")) {
742
- retName = retName.substring(0, retName.length() - 3);
838
+ if (!retName.contains("/")) {
839
+ if (retName.endsWith(".db")) {
840
+ retName = retName.substring(0, retName.length() - 3);
841
+ }
743
842
  }
744
-
745
843
  return retName;
746
844
  }
747
845
 
@@ -132,6 +132,60 @@ public class CapacitorSQLitePlugin extends Plugin {
132
132
  }
133
133
  }
134
134
 
135
+ @PluginMethod
136
+ public void getNCDatabasePath(PluginCall call) {
137
+ String folderPath = null;
138
+ String dbName = null;
139
+ if (!call.getData().has("path")) {
140
+ String msg = "getNCDatabasePath: Must provide a folder path";
141
+ rHandler.retPath(call, null, msg);
142
+ return;
143
+ }
144
+ folderPath = call.getString("path");
145
+ if (!call.getData().has("database")) {
146
+ String msg = "getNCDatabasePath: Must provide a database name";
147
+ rHandler.retPath(call, null, msg);
148
+ return;
149
+ }
150
+ dbName = call.getString("database");
151
+ try {
152
+ String databasePath = implementation.getNCDatabasePath(folderPath, dbName);
153
+ rHandler.retPath(call, databasePath, null);
154
+ return;
155
+ } catch (Exception e) {
156
+ String msg = "getNCDatabasePath: " + e.getMessage();
157
+ rHandler.retResult(call, null, msg);
158
+ return;
159
+ }
160
+ }
161
+
162
+ /**
163
+ * CreateNCConnection Method
164
+ * Create a non-conformed connection to a database
165
+ * @param call
166
+ */
167
+ @PluginMethod
168
+ public void createNCConnection(PluginCall call) {
169
+ String dbPath = null;
170
+ int dbVersion = Integer.valueOf(-1);
171
+ if (!call.getData().has("databasePath")) {
172
+ String msg = "CreateNCConnection: Must provide a database path";
173
+ rHandler.retResult(call, null, msg);
174
+ return;
175
+ }
176
+ dbPath = call.getString("databasePath");
177
+ dbVersion = call.getInt("version", 1);
178
+ try {
179
+ implementation.createNCConnection(dbPath, dbVersion);
180
+ rHandler.retResult(call, null, null);
181
+ return;
182
+ } catch (Exception e) {
183
+ String msg = "CreateNCConnection: " + e.getMessage();
184
+ rHandler.retResult(call, null, msg);
185
+ return;
186
+ }
187
+ }
188
+
135
189
  /**
136
190
  * CreateConnection Method
137
191
  * Create a connection to a database
@@ -141,8 +195,6 @@ public class CapacitorSQLitePlugin extends Plugin {
141
195
  public void createConnection(PluginCall call) {
142
196
  String dbName = null;
143
197
  int dbVersion = Integer.valueOf(-1);
144
- String secret = null;
145
- String newsecret = null;
146
198
  String inMode = null;
147
199
  JSObject ret = new JSObject();
148
200
  if (!call.getData().has("database")) {
@@ -166,7 +218,6 @@ public class CapacitorSQLitePlugin extends Plugin {
166
218
  }
167
219
  } else {
168
220
  inMode = "no-encryption";
169
- secret = "";
170
221
  }
171
222
  Dictionary<Integer, JSONObject> upgDict = versionUpgrades.get(dbName);
172
223
  try {
@@ -228,6 +279,30 @@ public class CapacitorSQLitePlugin extends Plugin {
228
279
  }
229
280
  }
230
281
 
282
+ /**
283
+ * GetUrl Method
284
+ * Get a database Url
285
+ * @param call
286
+ */
287
+ @PluginMethod
288
+ public void getUrl(PluginCall call) {
289
+ if (!call.getData().has("database")) {
290
+ String msg = "GetUrl: Must provide a database name";
291
+ rHandler.retUrl(call, null, msg);
292
+ return;
293
+ }
294
+ String dbName = call.getString("database");
295
+ try {
296
+ String res = implementation.getUrl(dbName);
297
+ rHandler.retUrl(call, res, null);
298
+ return;
299
+ } catch (Exception e) {
300
+ String msg = "GetUrl: " + e.getMessage();
301
+ rHandler.retUrl(call, null, msg);
302
+ return;
303
+ }
304
+ }
305
+
231
306
  /**
232
307
  * GetVersion Method
233
308
  * Get a database Version
@@ -246,12 +321,36 @@ public class CapacitorSQLitePlugin extends Plugin {
246
321
  rHandler.retVersion(call, res, null);
247
322
  return;
248
323
  } catch (Exception e) {
249
- String msg = "Open: " + e.getMessage();
324
+ String msg = "GetVersion: " + e.getMessage();
250
325
  rHandler.retVersion(call, null, msg);
251
326
  return;
252
327
  }
253
328
  }
254
329
 
330
+ /**
331
+ * CloseNCConnection Method
332
+ * Close a non-conformed database connection
333
+ * @param call
334
+ */
335
+ @PluginMethod
336
+ public void closeNCConnection(PluginCall call) {
337
+ if (!call.getData().has("databasePath")) {
338
+ String msg = "CloseNCConnection: Must provide a database path";
339
+ rHandler.retResult(call, null, msg);
340
+ return;
341
+ }
342
+ String dbPath = call.getString("databasePath");
343
+ try {
344
+ implementation.closeNCConnection(dbPath);
345
+ rHandler.retResult(call, null, null);
346
+ return;
347
+ } catch (Exception e) {
348
+ String msg = "CloseNCConnection: " + e.getMessage();
349
+ rHandler.retResult(call, null, msg);
350
+ return;
351
+ }
352
+ }
353
+
255
354
  /**
256
355
  * CloseConnection Method
257
356
  * Close the connection to a database
@@ -323,6 +422,29 @@ public class CapacitorSQLitePlugin extends Plugin {
323
422
  }
324
423
  }
325
424
 
425
+ /**
426
+ * IsDatabase Method
427
+ * Check if the database file exists
428
+ * @param call
429
+ */
430
+ @PluginMethod
431
+ public void isNCDatabase(PluginCall call) {
432
+ if (!call.getData().has("databasePath")) {
433
+ rHandler.retResult(call, null, "Must provide a database path");
434
+ return;
435
+ }
436
+ String dbPath = call.getString("databasePath");
437
+ try {
438
+ Boolean res = implementation.isNCDatabase(dbPath);
439
+ rHandler.retResult(call, res, null);
440
+ return;
441
+ } catch (Exception e) {
442
+ String msg = "isNCDatabase: " + e.getMessage();
443
+ rHandler.retResult(call, null, msg);
444
+ return;
445
+ }
446
+ }
447
+
326
448
  /**
327
449
  * IsTableExists Method
328
450
  * Check if a table exists in a database
@@ -140,4 +140,52 @@ public class RetHandler {
140
140
  return;
141
141
  }
142
142
  }
143
+
144
+ /**
145
+ * RetPath Method
146
+ * Create and return the capNCDatabasePathResult object
147
+ * @param call
148
+ * @param res
149
+ * @param message
150
+ */
151
+ public void retPath(PluginCall call, String res, String message) {
152
+ JSObject ret = new JSObject();
153
+ if (message != null) {
154
+ ret.put("message", message);
155
+ Log.v(TAG, "*** ERROR " + message);
156
+ call.reject(message);
157
+ return;
158
+ }
159
+ if (res != null) {
160
+ ret.put("path", res);
161
+ call.resolve(ret);
162
+ return;
163
+ } else {
164
+ call.resolve();
165
+ }
166
+ }
167
+
168
+ /**
169
+ * RetUrl Method
170
+ * Create and return the capSQLiteUrl object
171
+ * @param call
172
+ * @param res
173
+ * @param message
174
+ */
175
+ public void retUrl(PluginCall call, String res, String message) {
176
+ JSObject ret = new JSObject();
177
+ if (message != null) {
178
+ ret.put("message", message);
179
+ Log.v(TAG, "*** ERROR " + message);
180
+ call.reject(message);
181
+ return;
182
+ }
183
+ if (res != null) {
184
+ ret.put("url", res);
185
+ call.resolve(ret);
186
+ return;
187
+ } else {
188
+ call.resolve();
189
+ }
190
+ }
143
191
  }