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


Automation Direct Potentiometer Part No. ECX2300-10K picture

Automation Direct Potentiometer Part No. ECX2300-10K

$30.00



1pcs New MOELLER Potentiometer M22-R4K7 4.7k Ohms picture

1pcs New MOELLER Potentiometer M22-R4K7 4.7k Ohms

$31.26



Honeywell 53C22K POTENTIOMETER #K-2211 picture

Honeywell 53C22K POTENTIOMETER #K-2211

$40.00



Bourns 3500S-2-104 Precision Potentiometer picture

Bourns 3500S-2-104 Precision Potentiometer

$53.99



US Stock 10 Units 10K B10K OHM Linear Taper Rotary Potentiometer POT Blue Knob picture

US Stock 10 Units 10K B10K OHM Linear Taper Rotary Potentiometer POT Blue Knob

$17.63



10 turn Potentiometer 3590S Wirewound Variable Resistor Precision multi-turn POT picture

10 turn Potentiometer 3590S Wirewound Variable Resistor Precision multi-turn POT

$51.49







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