views:

122

answers:

1

I'm trying to come up with a best practice for sharing code among a group of Android applications. For example, suppose I have a content provider that I want to access from several Android applications. I'd like to have a class that contains static members for content URIs, column identifiers, etc. This class would be shared by the content provider implementation as well as the applications that use the content provider. What is the best way to do this in Eclipse? Thanks.

-rich

+2  A: 

For common libraries I've written I just compile into a jar. Then add that jar to the classpath of each project that needs it.

Michael Krauklis
Does this automatically load the contents of the jar into the apk for the dependent application? Will this work for custom UI widgets? We've run into problems with generated layout code for shared widgets.
rich
This will load the jar into the apk automatically yes (If you are using Eclipse anyway). No you cannot have layout XML inside jars, so it will not work for custom UI widgets.
mbaird
I second that yes, it will load the jar into the apk automatically. I can't comment on loading layout XML from a jar as I've never tried that.
Michael Krauklis