Sample data stored locally with a PhoneGap based app on Android - android

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.

Related

Android save custom data in APK

I have developed (Offline) Android app in which i have to save some employee's data into Local SQLITE database, when i send the apk into another andoird phone the data in the database dose not appear due to local storage of both the devices is different.
My goal is to send the data with the apk file to who ever i send the apk. How can i achieve the goal ?
The problem is i do not have the idea of how to do it, or never have done this kind of project before.
Please guide me.
If Your database is read only - You can use raw folder of project for Your SQLite database file, than, after .apk was installed, copy it, for example to external storage. But if You need changes in database and synchronized data on all devices - You should use only one server-side database.

how can i keep a folder in my mobile storage and a folder in my dropbox space in Sync?

i have developed a android app for farmers. it is a informative app for indian farmer.The users will be sending me the images and video files to me through my app. here i used (integrated) dropbox to receive those files directly to my dropbox space. whatever the image or video taken by the user, it will be stored on a folder in my mobile storage. Here what i want is, i want the folder in my mobile storage to be in sync with the folder in my dropbox.
How can i do this?
there is a app in market called Foldersync which exactly fulfil my requirement. how they are doing it? How can i keep a folder in my mobile storage and a folder in my dropbox to be in Sync?
Note :
i have gone through drop-box api and created a simple app to send files directly to my dropbox space and i know how to download a entire folder from dropbox.
But here my question is unique from that... pls don't answer the above points which i already know..
Please help!
Thank You
You can use the Dropbox API to keep a local client in sync with Dropbox. There are two main pieces to this:
1) Metadata:
Assuming you're using the Core API, the best way to get information about all of the file and folders in an account (or optionally under a specific path) is to use /delta:
https://www.dropbox.com/developers/core/docs#delta
With this, you can get information about everything your app can see, and then easily stay up to date with changes. There are some useful blog posts on using /delta here:
https://blogs.dropbox.com/developers/2013/12/efficiently-enumerating-dropbox-with-delta/
https://blogs.dropbox.com/developers/2013/12/filtering-dropbox-delta-results-by-path/
2) File content:
Using the metadata retrieved from #1, you can download any files you need access to locally using /files (GET):
https://www.dropbox.com/developers/core/docs#files-GET
You can upload locally changed files using /files_put:
https://www.dropbox.com/developers/core/docs#files_put
Or, for larger files, use chunked uploading:
https://www.dropbox.com/developers/core/docs#chunked-upload
https://www.dropbox.com/developers/core/docs#commit-chunked-upload
The main work here will involve programming the logic in your app to correctly receive changes from the server as well as upload local changes, in order to keep everything in sync.
Also, be aware that on mobile devices, bandwidth can be limited and/or expensive, so be careful to not accidentally automatically download a lot of data the user doesn't want or need.

HTML 5 local storage between app and browser

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.

What kind of database/storage does google keep chrome app use?

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.

Usage of databases in android application

I have a large data that I have to use in my first android application, could any one guide me the best way to achieve this?
Is there something like embedded database in android framework?
Can i keep my database on my custom server and provide web service to my application?
Which one of the above is better, since I can offer the user to purchase the application and keep the data locally on his device in compressed format.
Thanks
You can ship an android application with the database file in the res/raw folder, and then programmatically copy the file onto SD Card. I personally compress my database file into a zip and uncompress it on first run.
Android has support for SQLite databases which is a very efficient, embedded, crossplatform database. Would recommend this.
Using a remote server might not be a good idea, since signal on wireless networks is often slow and unreliable.
See this answer for me details.
Ship an application with a database
But if the file size of the compressed database is >1MB then you'll need to download it from a webserver and store it locally (Android has a 1MB file size limit on internal files/resources)
Here are some brief thoughts.
Android has SQLite, you could use that for storing and accessing data.
But there are restrictions on such file sizes of 1mb.
I'd recommend setting up a simple web server that can accept GET requests.

Categories

Resources