Help erasing persistent data

Discussion in 'Developers Corner' started by koopa_troopas, Jun 8, 2011.

  1. koopa_troopas

    koopa_troopas New Member

    May 18, 2011


    Hi! I have my application almost ready, but I still have a few doubts.

    I'm using the getBApp().getContext().setPersistentData() and getBApp().getContext().getPersistentData() methods in order to store a list of preferences ( I store a list of the user's favourite sites ).

    The problem is that I can't find a way to erase the information stored in a certain position of that list. Does anybody know how I could do it?

    And aslo , is this a correct and efficient way of storing the info, or i should use other ways??

    thanks folks!
  2. davidblackledge

    davidblackledge Registered l√úser

    Sep 9, 2008
    What that does depends on the host implementation.
    Here's the relevant portion of the sample Java Host's implementation which you're probably using:
        synchronized void saveSessionState(String compKey)
            if (state != null) {
                File file = getSessionFile(compKey);
    //            System.out.println("*** file for persistent state: " + file.getName());
                File dir = file.getParentFile();
                if (!dir.exists()) {
                try {
                    FileOutputStream out = new FileOutputStream(file);
                    try {
              , base.toString());
                    } finally {
                } catch (IOException e) {
        File getSessionFile(String compKey)
            String tivo = Misc.isWindows() ? "Application Data/TiVo" : ".tivo";
            return new File(System.getProperty("user.home") + "/" + tivo + "/"+ compKey + ".txt");
    "state" is a Properties object which uses compound keys that include the application and tivo ids.
    And storing just includes calling state.setProperty(key, value).
    So, you can't completely get rid of your data. The best you can do is store an empty string for the key. Since it's a Properties object which is a Hashtable, you can't even store null as the value.

    That said, this is all just the host implementation. Your software is running as a piece of the host. That means you can just do your own filesystem storage implementation and have complete control. The setPersistentData is just a convenient thing for quick and easy storage of small bits of info per-connected-TiVo.

Share This Page

spam firewall