2 Replies Latest reply: Jun 24, 2011 9:28 PM by DarrylBurke RSS

    How to store data in JavaFX 1.2 Mobile with Storage and Resource API

    866298
      I'm need to store some numbers and strings in an application that will be deployed in a HTC HD2 device with JavaFX 1.2 When run on desktop, everything works perfectly. But after being installed in the device, the application won't store data in files. I thought JavaFX was able to do that, according to its documentation (http://download.oracle.com/docs/cd/E17802_01/javafx/javafx/1.2/docs/api/javafx.io/javafx.io.Storage.html)

      I do it like this (just the part that stores integers)

      public var availableGifts : Integer[] = [0,0,0];
      ...
      var highscoresFile = Storage {
      source: "AvailableGifts.txt"
      }
      ...
      public function writeConfiguration() {
      try {
      var resource : Resource = configurationFile.resource;
      var outputStream : DataOutputStream = new DataOutputStream(resource.openOutputStream(true));
      outputStream.writeInt(availableGifts[0]);
      outputStream.writeInt(availableGifts[1]);
      outputStream.writeInt(availableGifts[2]);
      outputStream.flush();
      outputStream.close();
      println("Data stored!");
      } catch(ex : IOException) {
      ex.printStackTrace();
      }
      }

      The application is self-signed, just in case. But it won't store data in the mobile device... I need some help with this!