0

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.

Community
  • 1
  • 1
Blauharley
  • 4,186
  • 6
  • 28
  • 47
  • 1
    Why don't you just put all the code on the same plugin? or make your "plugin A" not beeing a plugin, just a helper class your plugin B uses – jcesarmobile Apr 03 '15 at 10:56
  • I actually try to avoid that simply because of code-duplication and code-maintainings. Are there no cordova/java methods that a plugin can use to communicate with another plugin? – Blauharley Apr 03 '15 at 11:21
  • 1
    but my point is, do you really need 2 plugins? do you need the javascript communication in both of them? I think using a helper class to access the database, and your plugin uses that class to get the data. As far as I know, you can't instantiate a plugin from another plugin, but you can use static methods from other plugins – jcesarmobile Apr 03 '15 at 11:35

2 Answers2

0

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

Blauharley
  • 4,186
  • 6
  • 28
  • 47
-1

it isn't possible from my point of view.

Johnson99
  • 7
  • 1