Back to Top

How to Save File in SD card using PhoneGap?

Save Image/File into sdcard in Android using Phonegap

Today I am going to explain about how to save an external image into your device’s SDCard in android using PhoneGap. PhoneGap is a framework for building mobile apps using HTML, JavaScript and CSS and known as Cordova.

Mostly we call web service and pass data as JSON format and we can easily fetch data for android application but sometimes when you fetching image from server it takes much time to load and even if no internet, image can’t be load.

[sociallocker]

So, To cache image or to save loading time of image from the server in every page load, we can store an image into local. It’s very easy to store an image into local using Phonegap.

Also READ: To setup SQLite for Android-Phonegap application

Let’s understand the code:

Here, I have called requestFileSystem which will create new storage for your app.I have used a LocalFileSystem.PERSISTENT file system which is not removed at browser’s discretion.There is also LocalFileSystem.TEMPORARY. The second argument is the size in bytes.

Must READ: To use JSON Resonse of Webservice in Phonegap Android

That’s it. Above code will help you to store an image into SDCard using PhoneGap.

As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates. [/sociallocker]

Comments (1)

  1. This will only save file to phone’s internal storage not in physical sd card.

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, fileSystemSuccess, fileSystemFail);

    will give a filesystem whose fullPath = “/”. But if you check the directory entry of this directoryEntry it will display the content of phone’s internal storage, not the content of the sd card.

    I’m wondering what phone did you test this on. I’ve tried it on 2 samsung and 1 alcatel and it behaved as I described it above.

    I am still looking for a way to make this work though.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to use Triggers in MySQL

Posted on 12 years ago

Bhumi

How to detect browser in Joomla

Posted on 11 years ago

Bhumi