Android – how to save / load data online (using Ajax and JSON to store data) and offline (local)

I need to help find the best, cross browser compatible way to "save" user input and store them locally (offline mode) and on the server (online). The program will be used by Android and IOS

I want to know the best way to track user progress when the device is online or offline

Hello, I've been studying Ajax, JSON, XMLHttpRequest, rest, Java and HTML5 (especially localstorage)

Scenario: (reading books online / offline, saving page progress)

>The user logs in to the web service, which allows the user to download the "HTML web book" (view it with HTML5 browser). > after each page turning, the rest API will publish the progress data to the web server using the get request. At the same time, create a JSON string and save it in the file on the server. (let's say "progressdata. TXT") > in the background, a separate "copy" of progressdata.txt It will be saved on the mobile device. Then the user leaves the Internet connection and continues to read HTML books. > when the user regains the connection, progressdata.txt will be uploaded to the server using the rest API, and it will update the old server file with the new. TXT file containing all user progressdata

Possible solutions:

The HTML5 localstorage solution looks good. JQuery even simplifies it: http://plugins.jquery.com/project/html5Storage

Direct JavaScript looks good for server-side storage, but it cannot access the physical hard drive of mobile devices, preventing any type of offline saving

Java applets look likely. In addition, it's not sure how Java runs on Android / IOS

I don't want to run the local host (PHP / Apache / Python) from the mobile device every time the user goes offline, but this may be the solution. I stumbled upon this powerful tool: http://couchdb.apache.org/

Question:

I need to know the best way to track user progress when the device is online or offline. What is the best way to do this?

resolvent:

Here are 2 screenshots that will help you solve the problem

They're in Ruby on rails, but maybe you can get the idea. It uses the HTML5 cache list

I hope it can help you!

http://railscasts.com/episodes/247-offline-apps-part-1

http://railscasts.com/episodes/248-offline-apps-part-2

Some more resources (sorry, I don't have experience with HTML5 cache lists myself)

http://diveintohtml5.ep.io/offline.html

http://developer.apple.com/library/safari/#documentation/iPhone/Conceptual/SafariJSDatabaseGuide/OfflineApplicationCache/OfflineApplicationCache.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>