Search code examples
androidcordovaandroid-sqlitecordova-plugins

Use a Cordova plugin within your own, is it possible?


My question bases on a shared database between two plugins. One plugin should handle database activities and the second plugin should take advantage of the first to get data from db and processing it.

As it is stated here it is possible to establish a shared sqlite-db between two apps so sharing a db between two plugins should be possible as well?

Theoretical example within a CordovaPlugin-Class of Plugin B:

@Override
public boolean execute(String actionAsString, JSONArray args, CallbackContext cbc) {

   // Theoretical code
   Plugin pluginA = new Plugin("A");
   SqliteResult result = pluginA.executeSql("SELECT * FROM project");
   ...
   ...
   return true;

}

How can a plugin be used within another plugin? Are there any examples? has anyone already done this? Or does a shared db-helper have to be used?

Thanks in advance.


Solution

  • Thanks @Johnson99. I solved it by using a cordova's api(cordova.exec) to communicate between these two plugins.