Question

Trying to use JSR 75 to access media saved under the '/home/video/' directory on the device. Using Blackbery JDK 4.6.1. Single line of code throws a 'FileSystem IO Error' Exception. Which is, as usual, unhelpful in the extreme.

fconn = (FileConnection)Connector.open("file:///home/user/videos/"+name, Connector.READ);

Has anyone tried to do this? I can open files within my jar, but can't seem to access the media folder. I have the javax.microedition.io.Connector.file.read permission set and my appplication is signed.

Was it helpful?

Solution

There are two kind of filesystems on BlackBerry - SDCard and store. You have to use one of them, defining it in the path. Standard directory on SDCard where video, music etc stored is "file:///SDCard/BlackBerry".

    String standardPath = "file:///SDCard/BlackBerry";
    String videoDir = System.getProperty("fileconn.dir.videos.name");
    String fileName = "video.txt";
    String path = standardPath+"/"+videoDir+"/"+fileName;
    String content = "";
    FileConnection fconn =  null;
    DataInputStream is = null;
    ByteVector bytes = new ByteVector();
    try {
        fconn = (FileConnection) Connector.open(path, Connector.READ);
        is = fconn.openDataInputStream();

        int c = is.read();
        while(-1 != c)
        {
            bytes.addElement((byte) (c));
            c = is.read();
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    content = new String(bytes.toArray());
    add(new RichTextField(content));

See also
SUN Dev Network - Getting Started with the FileConnection APIs
RIM Forum - Some questions about FileConnection/JSR 75
Use System.getProperty("fileconn.dir.memorycard") to check if SDCard available
How to save & delete a Bitmap image in Blackberry Storm?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top