How to show an Image from SDCard for different Platforms ?

Hi All,


In my App, i need to show images that are present in the SDCard. How can i access the SDCard ( i.e path to SDCard ) ?

My App is targeted to Platforms like Android, iOS, Blackberry, Windows Phone.

Can anyone please help me to do this stuff ??

Some line of code would be more helpful.

Thanks,

Ashis Kumar

Cross Platform Mobile Developer

Mindfire Solutions - Burn Ignorance

http://www.mindfiresolutions.com

Bhakta Ranjan S...
Hello,Use File API (http:/

Hello,

Use File API (http://docs.rhomobile.com/rhodesapi/file-api) to access content from SD card.

fileName = File.join('/sdcard/Android/data/', 'image1.jpg')

File.open(fileName)

Hope this will help you.

Thanks

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Darryn Campbell
Hollo, the problem is that we

Hollo, the problem is that we want to display an image stored in sd card, in <img> tag, how can you set src attribute with your code ? thanks

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Divyansh Madan
Try if this helps..http:/
Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Adel Sari
Thanks, but unfortunately it

Thanks, but unfortunately it dosn't help.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Bhakta Ranjan S...
Hi,If you want to display

Hi,

If you want to display your images by using <img src="img_file_loc">, then you can follow the steps mentioned below.

1: Use file API to do a binary read of image and write it into your application folder location .

2: After that use the path of image that recently copied to your application folder location.

You can use the below code to copy the image file from SD card to your application folder.

    file_testname = File.join("sd_location", 'test.png')

    test_content = File.binread(file_testname)


    file_name = File.join(Rho::RhoApplication::get_user_path(), 'temp.png')

    f = File.new(file_name, "wb")

    f.write(test_content)

    f.close


If you want to know more about File Api kindly follow  http://edgedocs.rhomobile.com/rhodesapi/file-api

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ashis Kumar
Thanks Bhakta, this solution

Thanks Bhakta, this solution worked for me.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Adel Sari
Thanks Bhakta, your solution

Thanks Bhakta, your solution works fine.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments