Is it possible in codename one to download a resource file from server, store it in phone memory, and open in application? It can be a good opportunity to support application after release.
Asked
Active
Viewed 174 times
1 Answers
2
Sure.
You can just download the file using a standard ConnectionRequest
and save it using the Storage
API. The Resources
class has an open
method that accepts an InputStream
for you to open this later on.

Shai Almog
- 51,749
- 5
- 35
- 65
-
Thank you very much! I did as you tell. I start my application, opened standart(minimal .res file). Then I download my full(updated) resource file using addToQueueAndWait, then use Storage.getInstance().writeObject((byte[]) event.getMetaData()). But when I load resource Resources.open(Storage.getInstance().createInputStream(Constants.RESOURCES)); got ugly exception – e8kor Jan 22 '13 at 11:18
-
java.io.UTFDataFormatException: malformed input around byte 10 at java.io.DataInputStream.readUTF(DataInputStream.java:639) at java.io.DataInputStream.readUTF(DataInputStream.java:547) at com.sun.lwuit.ui.util.Resources.openFileImpl(Resources.java:196) – e8kor Jan 22 '13 at 11:19
-
thanks God i fixed the problem using ByteArrayInputStream – e8kor Jan 22 '13 at 12:47
-
You need to either use writeObject with readObject. Or use createInputStream with createOutputStream. When you write an object additional meta-data is written not just the array. – Shai Almog Jan 22 '13 at 18:44