Options for Storing Images In SqliteDatabase - html

I am writing a PhoneGap application to work on Android initially.
I am writing it to collect images from the camera and store them in the database (a SQLite database using the HTML5 functionality for databases).
So there are two options, store the images in the database, and store the images on the SD card and reference them by filename.
So storing them on the SD card, how can I stop someone deleting them? I can't right, I mean they could remove the SD card too.
Storing them in the database, the HTML5 spec suggests that databases shouldn't be bigger than 5 MB, and if they are then the user will be asked if they want to increase the size. But perhaps this is not really an issue for a PhoneGap app?

My recommendation is to store the images as files on the file system. After you take the picture it will be on the SD Card but then you use the File API to move the images to /data/data/{app package name}. That directory is protected and the user is very unlikely to delete the files in that sandbox. It also has the added bonus that when your application is uninstalled that the directory is cleaned up.
This will get you around a host of issues with taking a picture and returning Base64 data. On a lot of phones the camera is so good that the base64 encoded string causes an out of memory error so I tell people to avoid the DATA_URL option whenever then can. Plus, now you store a lot less data in your DB and won't run into size limits quite so easily.

Related

HTML5 offline storage - photos and other content

I have a couple of questions about offline storage in HTML5. It's not an area I am that familiar with so I was hoping someone could shed some light.
I want to develop a web based system (for mobile) that a user could potentially use offline. Obviously the first time they'd use it (and any time they need to sync data thereafter), internet access would need to be required.
Some text data would need to be downloaded in json format. Basically this will be a list of certain items that will appear in auto-complete forms in the app (ie. even if the user is offline and they want to enter a type of animal for example, they'd type in "Gir" and "Giraffe", being one of the items downloaded in that json list, would appear in the auto-complete box.
I would like the user to be able to take photos at certain points. This would need to be saved internally, such that when internet access is available it can be synced/uploaded to some web server.
Could someone tell me if what I am thinking of is achievable?
Thanks
Use a cache manifest to keep offline portions of your app cached. You can also store key/value data in Local Storage, including text and blobs (which you should be able to convert to photos).
This demo (and its documentation) may be a useful resource for offline photo storage.

windows store app with photos as static content

I am making an windows store application and one of the requirements is that it must not use data connection. The application includes a lot of photos (around 400, all compressed as much as possible, around 8 kb each).
What would be the best practice handling this situation? How should I "preload" them in to the application?
If your requirement for zero net connectivity is real, then you have two options.
ONE. You can ship your app, and request that the user get the images from some other location and then give them to your app, loading the image in a somewhat manual way.
I know this does not sound ideal, but I wanted to acknowledge it was an option.
TWO. You can ship your app with the images embedded inside the installation package. This means as soon as your app installs, the user has all the images, no net necessary.
Here's how:
Create a new folder in your project, call it "Images" or something.
Drag your images into that folder (using Visual Studio).
Refer to your images like this "ms-appx:///Images/MyImage.jpg"
Note: it's up to you how you keep track of all your images, you could iterate through the folder over and over again, but it's probably best you just hard code the list in some class.
It's really that easy.
Best of luck!
Can you just store them in your project solution and refer to them in your code using the ms-appx:/// format?
Also if you are using so many images, prefer jpg images or compress your images using
https://tinypng.com/
Hope that helps.

Adding new BackgroundTransferRequest's once app is in background

Adding BackgroundTransferRequest's to the BackgroundTransferService once the app is in the background is successful, but the new requests don't actually run until the app comes back to the foreground. Not so great for my scenario of downloading lots of small files that may take a fair amount of time to complete.
I imagine Microsoft has probably implemented this behavior by design(?), but does anyone know a way around this or an alternative approach?
A bit of background to the problem:
I'm developing a Windows Phone 8 map app that allows sections of maps to be downloaded and cached for offline use. This process can lead to 1,000's of map tiles needing to be downloaded.
I've created a process that spawns the full limit of 25 BackgroundTransferRequest's, then adds more to the BackgroundTransferService as requests complete. This all works fine until the app actually goes in to the background.
I have considered doing some web server side processing to allow tiles to be bundled in to a zip and downloaded as a single request, but this is extra complication and will result in twice the space being required on the phone to complete the download and then extract the files before deleting the original package. But, ideally I'd like to find a way to force new BackgroundTransferRequest's to start running in the background.
It's not clear what your actual question is but I'd definitely recommend bundling them into a zip file and then downloading that. It's almost always easier to work with a single file than thousands.
If disk space is really a genuine issue (not just a theoretical one - I've put thousands of map tiles in under 20mb before, but it will depend on image complexity & quality) then you could make a few zip files. then you'd avoid the BTR issue and not take up as much disk space (even temporarily).

What methods are there to store data offline in a web-app

I need an offline caching system where my app can store about 0.5 MB of data. It is preferred that there is no interaction required by the user, but small amount of user interaction might be acceptable
Currently, Microsoft's Silverlight is being used to store data offline. It is a large download for the plugin, and not installed as standard on most machines.
I have been considering cookies - but they are far too volatile. I can imagine numerous reasons someone might clear their browser cache and lose all their data.
I am not sure about HTML 5 storage, and how volatile it is in practice.
I have been looking into flash, which is installed on over 97% of windows computers. It seems I can load data from a user selected file, and save data to a user selected file.
My questions...
How big is the microsoft silverlight plugin download (in MB) for windows? (I think about 8mb, but did not get clear answer from the internet)
How can users accidentally (or deliberately without realizing the consequence) clear their HTML 5 storage on common browsers?
Is there a way to get flash to store or load data from local files without user interaction?
Is there another alternative I have not considered?
Well you could use Flash shared Object storage, which will allow between 0 and unlimited space. Check this settings panel for details of your own settings to get a better idea of what I mean.
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager03.html
Of course this does mean that the user will have to allow third party flash content to be stored locally, which is the default. Also the default storage space is 100KB, with the user being prompted to allow for a larger amount unless they have previously increased the default themselves. So that's a small draw back, but still workable.
I am not sure how you would access the shared object from within a silverlight app, as I have only used it via a Flash swf. I will do some digging around using javascript and get back to you on that.
Also there is another post that may help you:
Javascript bridge to Flash to store SO "cookies" within flash
It sounds like what you need is isolated storage.
I use it with all my silverlight apps and it couldn't be easier to use. With only a few calls you can store and retrieve data programatically.
Edit: I was thinking that your app is already programmed in Silverlight. What is your app programmed in? Is it simply HTML/CSS at the moment?

How do I use Objective-c to upload/download a file on the internet?

This is for an iphone app. The file uploaded/downloaded on the internet would be a basic leaderboard with a username or id or some sort, and three separate highscores for three modes within one game.
Further - I would like to know if this can be achieved for free? For example could I upload an xml file or a plist file to a site like mediafire and still be able to upload there using objective-c? With mediafire, for example, I already got the download working using the NSArray method initWithContentsOfURL:. So far I have been unsuccessful in uploading to mediafire (Maybe using something with the NSURL password and host methods?). Is there a way to do this on mediafire? or would it require another way of doing this?
I don't really wish to use Apple's Game-center. Do you think MySQL is required?
I seriously doubt MediaFire will offer an easy to use upload API (or an easy to use download API for that matter). Also, what happens when more than one user updates their high score at the same time?
I don't think MySQL is required, however you have moved beyond simple push/pull of a file, especially since the file has global state. This is what GameCenter and OpenFeint have tried to solve for you already, and if you don't have at least a shared hosting account with server side scripting capability you won't be able to solve this issue in an acceptable fashion.