Is it possible to access the same local storage from a mobile app (ios/android) and a website? For eg, test.com stores value A in local storage and then would the mobile app be able to access this value?
HTML5 local storage API does not dictate the internal storage format. Therefore it will lead to ad-hoc code to use the internal storage format. Portability across browsers can be a problem because of lack of internal format specification. If your mobile app (native app) writes something to the local storage you should ensure the format is 100% compliant with the browser's internal storage format because you don't want the browser to be confused with the data when the browser has to read it. There can be surprises when both the browser app and the mobile app are running because both of them can update the data. Who wins if there are conflicting updates? How do you ensure data writes do not end up in garbled file in case both browser and mobile app happen to write data at the same time? How do you protect against such race conditions? At least HTML5 has no locking mechanism! Looking at all this complexity I believe it is not worth the complexity and the pain!!
I don't think your standalone web app will have access to the same data that you stored from the browser.
At least in the case of standalone app this data is stored in an sqlite3 db that is inside that applications internal storage folder so something like /data/data/com.your.package/databases/webdata.db I forget the precise name, but it's in a db there somewhere.
The browser I would assume does something similar but stores it inside of it's own storage area /data/data/com.android.browser/databases/. I don't think the browser or stand alone apps would take the time to go through all of the db's for every possible application on the phone to find the data. (if it even could, I think those files are actually private to the specific application on a stock device)
EDIT: The results are in.
No your app cannot access the key/value pairs that were stored from the stock browser (or any other browser for that matter). Nor vice versa, no other browser can access the data that your stand alone app stored.
Related
Am looking to build an app that would function like google keep.
just a light brush of the features:
Chrome app with offline storage - save online when internet is available
Android app and ios that would sync with the web server and also update locally and online
-single user
Am thinking that I would have a bridge(SERVER) of some sort to handle the imports and exports of data between different platforms. Thus emulate a sync.
Keep uses IndexedDB as it is the standard datastore available to Chrome Apps. You should be able to right-click on the screen and see the code (visit the Resources tab).
Chrome Apps also has Synchronised Storage that will manage offline and cloud access to your data storage. This means you can set a key on one machine the user has and see it updated immediately on the other machine of the user. The problem is that if you as a developer want to access and manage this data you can't do it, which is why Keep chose to use IndexedDB and manage the synchronisation themselves.
Ay used Index DB but it saves the content somewhere as indexdb only saves to the local computer. SO needs to be saved somewhere else.
We had initially planned on developing a native app for Android but PhoneGap is looking like a better option.
One thing we need to have is when the user installs the app, they need to have local access to a sample of the data in our back end database but have it stored locally. On the native app we had planned that when the user installed the app, the installation process would also trigger a retrieval of a chunk of the data in the back end database so that they could make basic usage of the app without relying on an internet connection all the time.
This data will include JPG files and perhaps some audio files. Will HTML5's local storage address this requirement?
short answer: YES
That's what makes phonegap awesome, you may create a database in to store the persisting data details (name & path)
When you run your application, you will test the connection, if there is no connection you can refer to the local files through your database else if there is connection you may download the new data, save them to the local database and then delete them from the local storage (Sdcard & database).
to find more check the phonegap's file docs
Just to add to what T.Baba has said, yes it is very possible, and I have recently built a webapp with PhoneGap and jQuery Mobile that does just that.
I used localStorage to contain all the data, and in particular localstoragedb. I haven't stored any images and/or audio files in localStorage and wouldn't recommend it anyway as most devices will limit the space to 5MB, but PhoneGap does give you access to APIs which will allow you to save files on the user's device. You can also of course bundle the files with the app and access them accordingly.
Indeed it is. Phonegap is best option for that.
I am aware that you can build a simple mobile app that doesn't require large local storage by using HTML5 local storage. However I'm wondering if it's also possible to build something that requires large storage: for example if your app needs to store lots of huge images.
I'm asking because HTML5 local storage is known to be limited to certain size on most browsers. I am not sure if this is the case even if you package it into an app.
I want to use an SQLite database in Android. I have few questions:
Is there a maximum size of database?
How secure is the data?
Where is the database stored?
How long will the data will remain on the phone?
Theoretically, it is calculated as 35 trillion bytes which should be way more than enough for your application because there's always limit to phone's memory. In short, you shouldn't be asking this question for a mobile app :)
If your phone is not rooted then the database stored in phone's internal memory is residing in the most secure storage area. Rooted phone does not offer any security to any file with in internal or external storage medium
If you don't provide any path, then the default/ideal location is phone's internal memory. And the file is placed inside data/data/package_name/database_file. This can be observed on emulator by exploring DDMS -> FileExplorer. If you save the file on other storage mediums, like sd-card, then of course it means you know where you are saving it :)
As long as your phone is functional and you don't wipe the app's cache, uninstall the app or do factory reset. No guarantees if you burn, crush, or spill water on your phone :)
Ok.. I will try and answer most of your questions..
1) Is the Data secure - Android stores app specific data in its app specific location and access is provided to only that application. So, we can say, its pretty secure, because no other app can read your app's data, unless access is provided to 2 applications having a same package name.
2) Location where db is stored - its under data\data\databases\packagename*.db
3) The data will remain on phone, unless the app is uninstalled / android crashes, in which case you would have to clear the phone cache and app cache, thus removing everything from android's inertnal phone memory.
I'm developing an app that would have an In-app purchase and download Videos from my server and store them on the device.
The problem is, the Videos are paid videos and are to be maintained in a highly secure place inside the app itself.
What are the possibilities of doing it? I had a look at setting android:exported="false", but it just restricts other apps to access my app's data. But how do I store the videos in a place which are restricted to be viewed by default even when connecting the device to a PC?
Are the apps allowed to store data in the device's \data folder? If so, please tell me how!
You can store files in your app's data folder, and as long as the phone isn't rooted, only your app should be able to access them.
However. The local storage on phones is generally limited, so storing videos there is a bad idea. Also, unless you're integrating your own video player, you might have issues trying to get the phone to play videos in your private folder.
To speak to the security issue, I'd suggest trying to keep them on the sd card, and experiment with either encrypting them, so they can't be read raw from disk, or (possibly) experimenting with file permissions, although I doubt the latter would work.
To do the encryption, I'd download the video, encrypt it and save it to the sd card. When you want to watch, decrypt and temporarily save to local storage for viewing. Not sure what kind of performance that will get, though. Plus, if you're relying on the OS to play your videos, you could have the same permission issues mentioned above. Depending on how critical this all is, you could explore something where the file/folder structure is obscured, so getting at them manually is more complex. Won't prevent all grab attempts, but will deter casual users.