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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Super Contributor
bh1r1th
Posts: 273
Registered: ‎11-23-2010
My Carrier: Software Programmer

how to open and get the image data from phone gallery in an application

hi friends,

i saw in some third party applications they are directly opend default phone gallery and they are taking that images to that application. how can i do that task please help me

 

Thanks in advance.

Please use plain text.
Trusted Contributor
govind23
Posts: 112
Registered: ‎05-20-2011
My Carrier: Developer

Re: how to open and get the image data from phone gallery in an application

 

try this...................

 

 

 

 

_filePicker = FilePicker.getInstance();
                    try
                    {
                         UiApplication.getUiApplication().invokeLater(new Runnable()
                         {
                             public void run()
                             {
                                 FilePicker fp = FilePicker.getInstance();
                                 FilePickListener fileListener = new FilePickListener();
                                 fp.setListener(fileListener);           
                                 fp.show();  
                             }
                         });
                     }
                    catch (Exception e)
                    {
                         UiApplication.getUiApplication().invokeLater(new Runnable()
                         {
                             public void run()
                             {
                                  Dialog.alert("Please check your data card..");
                             }                   
                        });
                    }



//FilePickListener class

class FilePickListener implements FilePicker.Listener
{  
    public void selectionDone(String str)
    {
        //             FileConnection file = (FileConnection)Connector.open(str);
                    byte[] data= getData(str);
                    Bitmap img=Bitmap.createBitmapFromBytes(data,0,data.length,1);
                   
                    } catch (IOException e) {
                        e.printStackTrace();
                        System.out.println("===================Exception: "+e.getMessage());
                    }
                   
    }
    private byte[] getData(String url)
    {       
        byte[] data = new byte[0];
        try
        {          
            FileConnection file = (FileConnection)Connector.open(url);
            int fileSize = (int)file.fileSize();
            data = new byte[fileSize];
            InputStream inputStream = file.openInputStream();           
            inputStream.read(data);
           
         
        }
        catch(Exception e)
        {
            System.out.println(e.toString());           
        }        
        return data;         
    }
}

Please use plain text.
Super Contributor
bh1r1th
Posts: 273
Registered: ‎11-23-2010
My Carrier: Software Programmer

Re: how to open and get the image data from phone gallery in an application

Thank you for the replay.

is this filePicker supports from 5.0 right but my app starts from 4.2

and please give me the picture paths means sd card path and internal memory card path.

please replay me

 

Please use plain text.
Super Contributor
bh1r1th
Posts: 273
Registered: ‎11-23-2010
My Carrier: Software Programmer

Re: how to open and get the image data from phone gallery in an application

hi

please give me the image gallery path

please urgent.

Thanks in advance.

Please use plain text.
Contributor
sandeepsagark
Posts: 39
Registered: ‎07-19-2011
My Carrier: airtel

Re: how to open and get the image data from phone gallery in an application

Try This
For SDCard
"file:///SDcard/"
for device memory
"file:///store/"
Please use plain text.
Super Contributor
bh1r1th
Posts: 273
Registered: ‎11-23-2010
My Carrier: Software Programmer

Re: how to open and get the image data from phone gallery in an application

thank you sandeep

i want the default image gallery path.

in that it will contains all images means internal images and sd card images, and camera options

 

 

i want to open this link it's in media->pictures

 

sample Gallery.png

Please use plain text.
Contributor
sandeepsagark
Posts: 39
Registered: ‎07-19-2011
My Carrier: airtel

Re: how to open and get the image data from phone gallery in an application

If you want all images from the device memory & sdcard memory, Just read both memories & if it is a image save the path. May be it will help you. I think Their is no particular path to get all the images from different folders. But i am not sure
Please use plain text.
Contributor
sandeepsagark
Posts: 39
Registered: ‎07-19-2011
My Carrier: airtel

Re: how to open and get the image data from phone gallery in an application

Try this
Add "Blackberry/pictures/" to the above paths
Please use plain text.
Super Contributor
bh1r1th
Posts: 273
Registered: ‎11-23-2010
My Carrier: Software Programmer

Re: how to open and get the image data from phone gallery in an application

Thank you for the replay sandeep

i saw in some appliations they are showing the images exactly prevously i am explained in that way they are showing images.

Please use plain text.
Super Contributor
bh1r1th
Posts: 273
Registered: ‎11-23-2010
My Carrier: Software Programmer

Re: how to open and get the image data from phone gallery in an application

sandeep i tried that

i am not getting that images.

Please use plain text.