Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Error using SD card program given on the blackberry site

Have you tried comparing the sample found here to your code: http://na.blackberry.com/eng/developers/devbetasoftware/widgetsdk.jsp

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 2
Registered: ‎01-21-2011
My Device: Curve 8520
My Carrier: Telcel

Re: Error using SD card program given on the blackberry site

Hi, there is the code implementation that I've in my project. Maybe it could guide U.

 

public void crearFile(){
        int campo8, campo9;
        DateField lafecha;
        SimpleDateFormat formato = new SimpleDateFormat("yyyyMMddHHmmss");
        try{


            lafecha = new DateField("", System.currentTimeMillis(), formato);
            FileConnection fc = (FileConnection)Connector.open("file:///SDCard/Blackberry/documents/"
                    + "visitas" + Inicio.clave + lafecha
                    + ".txt");
            if(!fc.exists()){
                fc.create();
            }
            OutputStream out = fc.openOutputStream();
            PrintStream output = new PrintStream( out );
            
            _vvisitas = (Vector)visitas.getContents();
            try{
                for(int idx = 1; idx<_vvisitas.size(); idx++){
                    StoreInfoSalida info = (StoreInfoSalida)_vvisitas.elementAt(idx);


                    for (int j = 0; j < 3; j++){
                        output.print(info.getElement(j));
                        output.print("\t");
                    }
                    
                    output.print("\n");
                }
                Dialog.inform("Data has been saved in a file into Blackberry SD Card "
                        + "Check it");
            }
            catch(Exception ex1){
                Dialog.inform(ex1.toString());
            }
            
            out.close();
            fc.close();
        }
        catch(IOException ioe){
            Dialog.inform("Data cannot saved in SD Card");
        }
        catch(Exception ex){
            Dialog.inform(ex.toString());
        }
    }