PhoneGap store HTML Files on Device

322 Views Asked by At

I have to build an App for Windows Mobile and iOS. So I decided to create this with PhoneGap.

The app should only display HTML-Files. These files are stored on a server and can change every day.

So I created already an API which delivers the files. My solution would be: In my PhoneGap-App I use AJAX to get the files (this is no problem and should already work...).

To the question: How can I store the files on the device? Is this possible with PhoneGap? The app have to work offline too (because of this I need to store the files)... And if this is possible: It should sync only the differences (between device/app and server) --> keyword rsync??

Thank you for your help! Emanuel :)

2

There are 2 best solutions below

0
On

Yes you can store files locally.

I would recommend the Phonegap File Transfer plugin for downloading files. It supports iOS and Windows phone 7 and 8 and can download and save the file locally. At the Cordova file plugin github you can see the paths where you can save the files for iOS, I haven't found a table for windows phone yet.

But I would not recommend you download the HTML files since they can be very big. You should dynamically create the mobile pages you need, since you would only need to download the displayed text and attributes for some HTML-tags.

The way you can do this is by having a server back-end where you can change the content of the pages. The plain HTML should then be saved in a database with a creation and modification timestamp(needed to check if you have the latest updates). You would then pull the data out of the database with your PHP and echo it as a JSON. Your app just has to make a AJAX-GET request to the server and save the data locally in a database. I would recommend the Cordova SQLite Storage plugin for the local database. Whenever a page is opened you should dynamically create a mobile page.

This way your app doesn't request huge amount of data from a server, which can be more appealing to your app users.

0
On

Have you checked here?

You can definitely store files locally on android platform.(I have already done that). However, I haven't done it on IOS.

So please investigate, if features I gave the link above, available for safari (IOS).

Synching only diff should be implemented on the server side and should be responsibility of your API.