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: 39
Registered: ‎02-06-2010
My Device: 9000
My Carrier: devloper
Accepted Solution

Read file holder information.

Hi,

 

I want to develop a program which is  read a files  from SDCard

 

like:

       abc.mp4

       123.txt

       xyz.3gp

 

plz give me idea about this !!!!

 



Developer
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Read file holder information.

Take a look at the sample application FileExplorerDemo that comes with the BB JDE.

--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Developer
Posts: 39
Registered: ‎02-06-2010
My Device: 9000
My Carrier: devloper

Re: Read file holder information.

[ Edited ]

hey 

 

Thank you for your replay!

 

i checked that I not getting it perfectly

I'm learning to develop a program to read a files from SDCARD

plz give me other solution of  this 

Developer
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Read file holder information.

Hi,

 

please take a look at the solution in this thread. It tries to open a file stored on the SD card. It is in a very simple form:

 

http://supportforums.blackberry.com/t5/Java-Development/Open-txt-file-from-mediacard/m-p/30965#M2362

 

hope that helps

--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Developer
Posts: 39
Registered: ‎02-06-2010
My Device: 9000
My Carrier: devloper

Re: Read file holder information.

[ Edited ]

hey

i dont like open file from SDCARD but

 

i want to devlope application like: -> In listfield set all files which is In SDCARD

 

like

123.mp4

456.mp4

789.mp4

 

how can i get all file name from SDCARD?

Developer
Posts: 77
Registered: ‎01-27-2010
My Device: Bold 9000
My Carrier: AT&T

Re: Read file holder information.

I'm going to reiterate that you should look in the FileExplorerDemo application that comes with the JDE.  

 

More specifically, look in the FileConnection class you'll see that there is a method called list() and a method called getName().  The list() method will return a list of all the files that are in the current directory so if you open a FileConnection in SDCard it might return a list like this:

 

 

  1. file:///SDCard/foo.txt
  2. file:///SDCard/bob/
  3. file:///SDCard/wow.mp3

 

Notice that item number 2 has a "/" at the end to indicate that it is a directory.  So if you want to find all the files in it you'll have to open a FileConnection to it and call the list() method on that connection.  To get just the file name and not all the path information open a FileConnection to a file and call the getName() method on that connection.  Here's how you should probably approach this.

 

 

  1. Open a FileConnection to the SDCard and call the list() method.
  2. Go through every element from list() and open a file connection to those.  
  3. If the connection is a directory (which you can find out with the isDirectory() method then call list again and recursively go through this process again.
  4. If the connection is a file call the getName() method and add it to your listfield.