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
Highlighted
New Contributor
Posts: 4
Registered: ‎04-15-2011
My Device: torch
My Carrier: rogers

FileConnection slow perforance

i'm writing an app need save more thant 200 files in SD card. i'm using FileConnection to create new file and write content to it.

it works ok in simulator only seveal seconds. but in real device (torch 9800), it took around 10 MINS to save the 200 files (each only has less than  1k data). 

 

following is how i use FileConnection to save file,

 

FileConnection fc = null;

OutputStream os = null;

 

for (int i = 0;i<size;i++){

...

fc = (FileConnection) Connector.open(bkDirectory,Connector.READ_WRITE);

if (!fc.exists())

{fc.mkdir();

fc.close();

}

os = fc.openOutputStream();

os.write(contactBuf.toString().getBytes());

os.close();

 

}

 

any idea how to improve the performance?

 

thanks

New Contributor
Posts: 2
Registered: ‎06-06-2011
My Device: 9800
My Carrier: att

Re: FileConnection slow perforance

maybe you are doing this operation in the event thread?
Contributor
Posts: 23
Registered: ‎04-27-2011
My Device: blackberry torch 9800
My Carrier: Claro

Re: FileConnection slow perforance

Hi:

 

I have a similar problem: i have 400 html files with no more than 3k each and in the simulator it takes no more than 40 seconds but in real phone it takes about 4 minutes, and about even thread: I am doing this:

 

From my ParentItemsScreen which extends from MainScreen I call a thread and all the logic to move those 400 files is done in my Class which extends form Thread spomething like this

 

ProcessThread process = new ProcessThread();

process.start();

 

As you can see I made all the process in my ProcessThread which extends from Thread, Do am i missing something?

 

give an idea please, Thanks

 

Developer
Posts: 202
Registered: ‎04-19-2011
My Device: Blackberry Bold 9780
My Carrier: TAM

Re: FileConnection slow perforance

this is just my suggest or tips:

1. Make this (saving image method) in a different thread.. Don't include in event thread, it'll be hang.

2. adding a loader screen (Please Wait Screen) for waiting the operation to be done...

 

correct me if i'm wrong

New Contributor
Posts: 4
Registered: ‎09-10-2011
My Device: 9800
My Carrier: Rogers

Re: FileConnection slow perforance

I am having the same problem.  Has anyone found a resolution for this?  Any help would be appreciated as we've been struggling with this for a few weeks!

Contributor
Posts: 23
Registered: ‎04-27-2011
My Device: blackberry torch 9800
My Carrier: Claro

Re: FileConnection slow perforance

Hi everyone:

 

Just to say somalething fin about this topic, this is what i found after many testing:

Blackberry devices are slower than other devices (android, iphone) and because of that when we try to move or copy any stream file such as .html (in my case) it takes too much time in real devices (tested in storm 9550 and torch 9800), so the final solution for me was this:

 

"Instead of copy my 400 html files when the application is installed and starts running I just copy images files (I am not sure why but images files are copied faster than html, text, files), so I just copy the images files and when my application starts and I really need to show any html, first I asked if the html exists in any path inside thephone (not copied the first time) if not then I search it in the assests folder and i just copy it to the any path in the phone and show it in my app"

 

this way i just copy the html file one by one when is requested and not all at once when the application start, doing it this way my application just takes only 30 SECONDS even copyng the images files (faster than html files).

 

SO, i suggest to just copy files when they are needed, this was my solution and everybody was happy with me ah the office because I reduced 4 MINUTES to 30 SECONDS (remember that it used to take me 4 minutes because of the html files when i was trying to copy them into the phone when the appication stars)

 

Regards,

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: FileConnection slow performance

Did you have a large number of html files and relatively few image files?  If so, I suspect the problem was not the html or image format of the files, but instead was the number of files - at least that is my experience.  See this Thread:

http://supportforums.blackberry.com/t5/Java-Development/File-system-access-delete-and-create-FileCon...

Contributor
Posts: 23
Registered: ‎04-27-2011
My Device: blackberry torch 9800
My Carrier: Claro

Re: FileConnection slow performance

Hi,

 

In my case I had 400 images files and about 800 html files, but when i was testing which kind of file takes so much time the answer was the html files even when i use only 400 html files, no idea why this happens b/c it suppossed to be just bytes[] , but not sure why that happens but that was the problem I found and the solution I made.

 

Regards,

New Contributor
Posts: 4
Registered: ‎09-10-2011
My Device: 9800
My Carrier: Rogers

Re: FileConnection slow performance

We ended up going with Peter's suggestions and it works - overall seems to be the best approach.  Thanks Peter - much appreciated.