Phonegap localStorage not backing up to iTunes - javascript

So I'm building an app using Phonegap and have come across an issue in my ad hoc testing phase.
After installing the app on my iDevices, I've tried to back up the data contained within localStorage to iTunes. For some reason, none of the things I've saved to localStorage seem to be retrieved when I re install the app. I've changed BackupWebStorage in my config file to "local" but that has not helped.
I know that ios 5.1 created many issues for localStorage being backed up and am wondering if that's still the case. If so, what would be my best alternative to localStorage? I'm content with using the File API or a local SQL database, I just need some direction before I rewrite a large amount of code.
Thanks!

Related

Where does sqlite store the database file on win7 offline?

I'm following this, using js in html to call 'openDatabase("AddressBook",....'. It works, it stores values and calls them them back correctly when I reopen the page but I can't find where the AddressBook DB file is. I've searched my pc, C:\ and appdata etc but I can't find it. I've tried downloading the sqlite3 tool and setting a DB separately and transporting it to the folder but it doesn't seem to recognize it. If I change the name of the DB called it starts a new one and if I then put the previous DB name it shows the stored DB from before. I'd like to know I can locate it and transport it before I learn anymore.
Can anyone advise where it might be?
Is there a way to force it into the same folder as the js files?
That guide seems seems to misunderstand the APIs that it is using. It keeps saying that its using SQLite. It's not. It looks like it is using the deprecated WebSQL spec. The file isn't in your filesystem, it's part of the browser's internal storage and there is no guarantee of how the browser is actually storing it so you can't directly access it from outside the browser.
I'm making the assumption that it is using WebSQL because it mentions using openDatabase and executeSql. WebSQL has been deprecated and is no longer maintained in most browsers. You can get a detailed reasoning from this answer Why is Web SQL database deprecated?. That guide you're following is also 9 years old and doesn't even discuss WebSQL's deprecation.

Where does react native store assets?

Hi I am developing a react native android app, and I noticed that video assets only work when the device is connected to the internet. That leads me to the question: where does react native store video assets?
To add clarity: I'm using the require syntax for local file (i.e : source={require('assets/file')}; so the files are all inside the actual directory of the folder)
Are the video assets being hosted on a hosting service? (If so, how does this work, why do they do this, and who is paying for this hosting? I'm definitely not paying for anything right now).
Finally, how can I get my videos to work offline? (I've been searching for days and haven't found any solution for this and no mention of this in the actual docs).

Create hybrid desktop and web application with different languages

I want to create an app to estimate engineering costs: lots of tables, forms, a sidebar with a tree structure and so on. You can access a database in the cloud and create table structures according to records in the database.
Naturally that would be a website, however, if the user does not always have an access to the Internet, he/she can download a copy of that database (precisely, a copy of the current version of the database), so that it would be possible to get data from it and work locally. That is why an offline desktop app is needed.
Would it be possible to develop such a hybrid application without first creating a web app and then doing the same with a desktop app?
Previously i have looked into JavaFX, but we saw that it's too difficult to create a website out of that. Then we saw Electron, but i'm not sure if it is the right choice, because it seams that Electron is only used for desktop.
I'm lost as to why you feel you need a website/desktop hybrid. There are many APIs available to let you access a cloud database. All you have to do is find an API with web hooks, or APIs that specifically target the database type you are using (sql, mongo, or whatever). Then just cache a local copy once you've pulled down the database.
Work on the copy then push back to the database when they save, or try to do a push/pull every 5 minutes or something.
You can make a HTML page, which would:
Use AJAX calls if connected
Add relative <script> tag, thinking that HTML file lies in a folder on PC, and that script is somewhere nearbly.
In both cases, user will get same results.
Downloads are:
HTML file with inline script
JS file with database
or
zipped folder with HTML, database JS files and all scripts, images, css, etc. requred for HTML file to show properly.

Force live users to expire assets for JS Web Apps

Our web application is built on AngularJS and Ruby on Rails. Sometimes we find a bug in the JS and need to patch it immediately. We push up an update to Heroku and the new JS files are then live. However, users on the site (who are currently on the site) and do not refresh their page, are still using the old JS file.
Is there a way to force refresh of the assets on deployment with Heroku? Or, is there a better way to handle this type of problem?
I am thinking of using web sockets to possibly handle the scenario.

PhoneGap - Read pre-packaged sqlite database

I've been struggling to get this working for too long. I just started to get into PhoneGap/Cordova. I got the demo app running, installed all official plugins, and added this SQLite plugin to begin work with: https://github.com/brodysoft/Cordova-SQLitePlugin
However, I want the plugin to read a pre-packaged database. Simply put, create an app that works offline and does not need to download an SQLite database when it is run for the first time.
I have been developing for Android for quite some time, and the solution was to deploy a read-only database file in the assets folder, and on first run copy the database file into a different folder, where I can read/write as I please.
So I did a little research and realized that it SHOULD be the same with PhoneGap. Place a binary SQLite database somewhere, so that when built, it will be packaged with the app. And then simply load it with the SQLite plugin I linked here.
Finally, the question! What are the exact steps I have to take to be able to read a file that was packaged with the app?
Where should I put my binary file to ensure that it gets packaged into the app?
How exactly should I initialize the File API? Should I ask for persistent storage using window.requestFileSystem? Or should I get some (not sure which) directory (cordova.file.applicationDirectory) as a DirectoryEntry using window.resolveLocalFileSystemURL? If so, what are the EXACT parameters I should use? I am mostly referring to this: https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md
How do I read the packaged file? Using window.resolveLocalFileSystemURL with the right folder? What should then the parameters be?
File copying should work OK if I get to this point. Just copy from the read-only cordova.file.applicationDirectory into cordova.file.dataDirectory, which is read/write. Right?
I know the questions might be pretty basic, but my countless attempts were unsuccessful and I did not find a tutorial that explains this in-depth (believe me, I googled). Also, the documentation seems insufficient.
Just working with a WebSQL database and load data the DB using a s***load of INSERTs is not a viable option, the database has thousands of records.
Thanks for the help in advance, you will save me a headache or two.
Currently Cordova's standard SQLite Plugin supports Pre-populated Databases, which will copy your database file from www and put it into the right directory. It also supports Android as well as iOS, so you don't need to have different logic for different platforms.
When you open the database, you can specify that it is pre-populated using createFromLocation: 1 like this:
var db = window.sqlitePlugin.openDatabase({
name: "my.db",
createFromLocation: 1
});
For iOS, it will first check www and if the file exists, it will copy it to Documents. Keep in mind that it will be backed up by iCloud. If you want to exclude it from iCloud, then add location: 2 on openDatabase as well, which will put your databases in Library/LocalDatabase.
UPDATE (2016)
The original Cordova-sqlite-storage project does not support pre-populated db anymore.
However, this feature just moved to another project from the same creator. Now, use Cordova-sqlite-ext for this purpose.

Categories

Resources