BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 11-25-2008, 09:58 PM   #1
viskaya
New Member
 
Join Date: Oct 2008
Model: 8310
PIN: N/A
Carrier: Indosat
Posts: 10
Default Create file xml, succeessful on simulator but failed on device

Please Login to Remove!

Hi all,

i am trying to create file xml on SDCard. It is successful on simulator but when i deploy the app to device, the file creation failed. Does any body know how to solve it or something wrong with my code ?

Note that my app has been signed with RRT, RBB, RCR

here is part of my code :

private String sdCard = "file:///SDCard/BlackBerry/";
private boolean fileExists;

public void open(String fileName) throws Exception{
this.fileName = fileName;
fConn = (FileConnection)Connector.open(sdCard+fileName, Connector.READ_WRITE);
this.fileExists = fConn.exists();
}

public void write(String content) throws Exception{
if(fileExists){
fConn.delete();
}
fConn.create();
fConn.setWritable(true);
outStream = fConn.openOutputStream();
outStream.write(content.getBytes());
//outStream.flush();
}

public boolean fileExists(){
return fileExists;
}
Offline  
Old 11-26-2008, 12:24 AM   #2
srehmani
Knows Where the Search Button Is
 
Join Date: Mar 2006
Location: TX
Model: 8700g
Carrier: TMO
Posts: 27
Default

is your application signed?

BlackBerry - Java Code Signing Keys
Offline  
Old 11-26-2008, 12:32 AM   #3
viskaya
New Member
 
Join Date: Oct 2008
Model: 8310
PIN: N/A
Carrier: Indosat
Posts: 10
Default

Yes it is. I had stated it at my first post.
Offline  
Old 11-26-2008, 06:18 AM   #4
robinShazam
Knows Where the Search Button Is
 
robinShazam's Avatar
 
Join Date: Oct 2008
Location: london, uk
Model: 8120
OS: 4.3.0.67
PIN: N/A
Carrier: Lots
Posts: 15
Arrow

Do you get any exceptions?

Is the card write-protected (some have that cheeky little write-protector switch on them.)

Does the folder "Blackberry" exist on the sd card? (it will not be created automatically.)

Can you at least read from the card? I use the function below to scan all folders and report them - see if that works for you. Apologies for the slack string appending!

Code:
...
scanFolder( "SDcard/", 0 );
...
...


	private void scanFolder( String path, int deep ){
		FileConnection fc = null;
    	
		try{
			fc = (FileConnection)Connector.open( "file:///" + path );
			Enumeration fl = fc.list();
			while( fl.hasMoreElements() ){
				String file = (String)fl.nextElement();

				boolean bDir = false;
				FileConnection fd = (FileConnection)Connector.open( "file:///" + path + file );
				try{
					bDir = fd.isDirectory();
				}finally{
					try{ fd.close(); }catch( Throwable th ){ ; }
					fd = null;
				}

				if (bDir){
					StringBuffer sb = new StringBuffer();
					int i = 0; 
					while( i++ <= deep ) sb.append( "  " );
					sb.append( file );
					// report directory name here

					scanFolder( path + file, deep+1 );
				}
			}

		}catch( IOException ioe ){
			// report ioe here

		}catch( SecurityException se ){
			// report se here

		}catch( Throwable th ){
			// report th here

		}finally{
			if (fc != null){
				try{ fc.close(); }catch( Throwable th ){ ; }
				fc = null;
			}
		}
	}
Offline  
Old 12-03-2008, 11:40 PM   #5
viskaya
New Member
 
Join Date: Oct 2008
Model: 8310
PIN: N/A
Carrier: Indosat
Posts: 10
Default

Hi robinShazam,

The exception message is 'File system error'. Do you have any idea ?


thx,

Vis'
Offline  
Old 12-04-2008, 02:17 AM   #6
maokejackson
New Member
 
Join Date: Nov 2008
Model: 8310
PIN: N/A
Carrier: no
Posts: 5
Default

public void write(String content) throws Exception{
if(fileExists){
fConn.delete();
// reopen
}
fConn.create();
}

After deleting a file, you have to reopen file connection.
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Tenma Audio Impedance Tester 72-6948 picture

Tenma Audio Impedance Tester 72-6948

$64.95



ESI IMPEDANCE BRIDGE MODEL 250-C1 For Parts Untested picture

ESI IMPEDANCE BRIDGE MODEL 250-C1 For Parts Untested

$65.00



General GenRad  Labs 1658 Precision RLC Digibridge Impedance Meter picture

General GenRad Labs 1658 Precision RLC Digibridge Impedance Meter

$350.00



TC ESI Impedance Bridge Model 250-DA Serial 1394 Electro-MeasurementS Oregon USA picture

TC ESI Impedance Bridge Model 250-DA Serial 1394 Electro-MeasurementS Oregon USA

$69.99



Digital Ohmmeter LCD Audio Impedance Test Meter Speaker Voice Resistor System picture

Digital Ohmmeter LCD Audio Impedance Test Meter Speaker Voice Resistor System

$56.99



Gold Line ZM-1P Impedance Meter with Protection Relay picture

Gold Line ZM-1P Impedance Meter with Protection Relay

$648.98







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.