I am embedding Apache Felix into an android application. Starting and stopping the bundles work fine. But I would like to update a bundle by reading another bundle file. Here's my code:
bundle1 = bundleContext1.installBundle("file:sdcard/Download/AndroidImageViewer_1.0.0.201308221559.jar");
bundle1.start();
bundle1.stop();
try {
bundle1.update(new FileInputStream(new File("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar")));
} catch (FileNotFoundException e) {e.printStackTrace();}
bundle1.start();
I expected this to work, and that my bundle will get updated, but unfortunately, I got the following error:
java.io.FileNotFoundException: /file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar (No such file or directory)
at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:239)
This exception occurs at the following line:
bundle1.update(new FileInputStream(new File("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar")));
I am totally sure that the bundle AndroidVideoPlayer_1.0.0.201308231205.jar
exists in the Download directoy, and I tried to start it previously and it worked fine. I am confused. Any help? Thanks.
Ah, you are creating a File object from a URL!
new File("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar"))
Try this
File file = new File( "sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar" );
context.update( new FileInputStream(file));
Or
context.update( new URL("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar").openStream());