O'Reilly logo

BlackBerry Java Application Development by Bill Foust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - storing data to a file

  1. Add the data member declaration to the class about the constructor.
    protected String _URL = "file:///SDCard/BlackBerry/Journal.data";
    protected String _SDCardURL = "file:///SDCard";
    protected String _SaveDirURL = "file:///SDCard/BlackBerry";
    
  2. You need to add a helper method to the Screen class. Insert the following CheckPathExists method into the class.
    protected boolean CheckPathExists(String path)
    {
    boolean return_value = false;
    try
    {
    FileConnection fileConn = (FileConnection) Connector.open(path);
    if (fileConn != null)
    {
    if (fileConn.exists())
    {
    return_value = true;
    }
    }
    fileConn.close();
    }
    catch (IOException e)
    {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    return return_value;
    }
    
  3. Then, you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required