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

Java Development

Reply
Developer
Posts: 185
Registered: ‎09-02-2010
My Device: Not Specified
Accepted Solution

What may be the problem...?

 

Hi, 
By using this app we can create new folder using  Fileconnection..
this is my code it works fine without Dialog.alert(" ");  message..while im using Dialog it's showing an exception push modal screen..
what may be the problem...
public class CreatingFolderApp extends UiApplication
{
	public static void main(String args[])
	{
	
	CreatingFolderApp cfp=new CreatingFolderApp();
	     //cfp.setAcceptEvents(false);
	       cfp.enterEventDispatcher();
	}
	
	 CreatingFolderApp()
			 {
		 
		  Dialog.alert("Creting folder!!!");
				FileConnection fc = null;
				try
				{
					fc = (FileConnection)Connector.open("file:///SDCard/testfolder3/");
				
				
				if(!fc.exists())
				{
				
		        	fc.mkdir();
				
				}
				else
				{
					Dialog.alert("Folder name alredy exists");
				}
				fc.close();
			 }
				 catch (IOException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
	
}
}
}

 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: What may be the problem...?

Since you are trying to display the alert in the constructor of your application class, this is done prior to entering the event dispatcher. You cannot display a dialog until you actually enter the event dispatcher.

 

Developer
Posts: 185
Registered: ‎09-02-2010
My Device: Not Specified

Re: What may be the problem...?

Hi RexDoug ,

 

                        Actually I used the  cfp.enterEventDisptcher(); method

 

 

Developer
Posts: 185
Registered: ‎09-02-2010
My Device: Not Specified

Re: What may be the problem...?

Can anyone help me please............

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: What may be the problem...?

[ Edited ]

I'll stand by my original post.

 

Check your code - you enter the dispatcher AFTER the constructor is completed. Your alert dialog is IN THE CONSTRUCTOR!!!

 

Am I wrong?

 

If you single-step this code in the debugger, you sill see what I mean.

 

Developer
Posts: 374
Registered: ‎04-07-2010
My Device: Bold 9000
My Carrier: Airtel

Re: What may be the problem...?

RexDoug is Right... you cannot first display Dialog and then enter the Dispatcher.....
Press the Like button (Thumb up) on the left side to thank and
please mark the Thread as solved if its solved...
K.S
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: What may be the problem...?

Have you read what RexDoug has said?  Try re-reading it - it has the exact answer to your problem.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 185
Registered: ‎09-02-2010
My Device: Not Specified

Re: What may be the problem...?

Hi RexDoug,

 

                     Absolutely u are right...Thanks for giving me answer...