Well, you can dynamically load the jar file from the SD card using the DexLoader class ... which you can update whenever you want ... on your storage ... below is the working code.
final String libPath = Environment.getExternalStorageDirectory() + "/test.jar"; final File tmpDir = getDir("dex", 0); final DexClassLoader classloader = new DexClassLoader(libPath, tmpDir.getAbsolutePath(), null, this.getClass().getClassLoader()); final Class<Object> classToLoad = (Class<Object>) classloader.loadClass("com.test.android.MainActivity"); final Object myInstance = classToLoad.newInstance(); final Method doSomething = classToLoad.getMethod("doSomething"); doSomething.invoke(myInstance);
and in your file library file might be like
public class MainActivity { public void doSomething() { Log.e(MainActivity .class.getName(), "MainActivity : doSomething() called."); }}
tell me if you need help
Harry sharma
source share