I have an android application which has to load dynamically class ,an undefined number of a jar class which implemented an interface.
In fact, I look at a directory
It would also be a good idea to use the ClassLoader rather than the Dalvik path class loader:
ClassLoader cl = new DexClassLoader(url, ApplicationConstants.ref_currentActivity.getFilesDir().getAbsolutePath(), null, ModuleList.class.getClassLoader());
Where url is the location of the file you are loading "from". ApplicationConstants.ref_currentActivity is simply an activity class - my implementation is fairly complicated due to dynamic modular loading - so I needed to keep track of it this way - but others can probably just use "this" if that class is already an activity.
The MAIN reason for using the class loader over the dalvik one - is that it doesn't require files to be written to cache, and therefore the permission chmod 777 /data/dalvik-cache is unrequired - and of course you also wouldn't need to pass this command from root on a rooted phone pro-grammatically either.
It's always best to not have users forced to root their phones, simply because your app requires it. Especially if your app is a more professional "meant-for-company-use-type" -.Work Policies against the use of rooted phones are usually in place too.
If anyone has any questions on modular loading - please feel free to ask. The base of my current code is all thanks to Virginie Voirin, along with my own modifications. Good luck all!