Where to store data in Sencha Touch? - sencha-touch

I have following case to handle:
My mobile application ( Sencha Touch App wrapped in native container ) has around 5000 book titles. Now, I don't want application to ping server to get these books on his mobile. Application will need to access this data during run time. So should I
a) dump the data into sqlite at the time of installation of the application ? (First time run)
b) Fetch data from files only. ( I will be making sorting and querying operations over this data - may not be a good solution if I store the entire file in an array at once and process it further )
Kindly advice.

Create a JSON API to fetch your data from a database on the server.

You can store this data in JSON file and then use JSON proxy to load/sort/query it.
BUT its better to expose a web service, just like what Diodeus said.

Related

How to dynamically load localization resource data without rebilding the application?

I'm using localization in my Blazor Server app. I need to add key, value pairs to localization resource file programmatically. I have inputs in my UI. User will able to add key, value pairs through the application UI. But after that I need that inserted data to be available with localization(After refreshing the browser) without re-building the application. Is there a way to dynamically load .resx resource file data without rebuilding the application in Blazor Server app after it get changed while running?
If I understand your request:
You can store the resource strings to database and create a Cache to store the last updated data of resources.
It's work fine if your resource less than 4MB.

Simplest way/tool to automate API calls and to save Json results in a file?

What would be the simplest tool/editor (ideally for Mac) to run web API queries (Stateless RESTful web API) in a loop in order to store Json results in a file ?
Very simple basically, trying just to automate the following :
- a first call to get a list of IDs
- then for each each ID, doing a call to get a few values related to this ID. Values are returned in a Json file, I would like to store them in a file (csv or excel)
To test the queries, I've used "Advanced REST client" to set a request with my authentication information header and do a few API queries tests, it works well but now I basically want to create a script to get the whole set of data which is returned and save in a file. With the idea to run this script from time to time. You can't to that with "Advanced REST client", right?
Sorry it's not (yet!) a super advanced question but any help would be greatly appreciated.
You may try Postman - definitely works on (accursed) Mac

Sencha Touch LOcal Storage on Mobile Apps

I am planning to use Sencha Touch for an application of my company. I read that local storage stores data on client's browser. MY problem is when I build the code to native app using Sencha CMD how does the local storage work? What is the alternative of local storage to keep some data suppose user details (so that user doesn't need to login always).
Advance Thanks
localStorage
Is a very easy to use interface that works synchronous. It stores strings (you can JSON.stringify other Javascript objects) as key-value pairs and you just set the value with a key in this way:
localStorage.setItem('key', 'value');
To read:
var value = localStorage.getItem('key');
which returns value or null if key wasn't found in the storage.
You can use it as an object:
localStorage['key'] = 'value';
var value = localStorage['key'];
however, this is not the recommended approach. In this case undefined will be returned for non-existing items.
More details:
http://www.w3.org/TR/2013/PR-webstorage-20130409/
http://diveintohtml5.info/storage.html
IndexedDB
Database that sort of replaces the now deprecated Web SQL. It works asynchronous and is a bit harder to understand as it uses stores, requests and transactions to deal with the data.
You can store any kind of objects in IndexedDB (Javascript objects, Blobs (files)).
You can also request storage space. User will be alerted if you need more than 5 mb (5 mb is not defined, but seem to be the limit most browsers set before asking user for permission).
See here for details on how you can use it:
http://www.w3.org/TR/IndexedDB/
http://www.html5rocks.com/en/tutorials/indexeddb/todo/
Web SQL
Although, as mentioned, deprecated it is still supported in browsers such as Safari. Is a database that works with SQL-queries and request, and works asynchronous.
Here are more details:
http://www.w3.org/TR/webdatabase/
http://html5doctor.com/introducing-web-sql-databases/
File API
Currently only supported in Chrome. Is a virtual file-system that works asynchronous as IndexedDB but is intended for large files (video and audio files etc.) but can just as easily be used for storing other data.
You can store any kind of objects in File API as Blobs (files). As it is a virtual file system you can navigate using folders.
You can also request storage space here as well (quota).
For details:
http://www.html5rocks.com/en/tutorials/file/dndfiles/
http://www.w3.org/TR/FileAPI/
And of course there is cookies and for IE UserData, but these are very limited.
This example demonstrates how to use local storage with Sencha Touch model objects:
http://www.mysamplecode.com/2012/06/sencha-touch-local-storage-example.html
If you're wanting to switch & sync data from online to offline you might also be interested in this example:
https://www.robertkehoe.com/2012/11/sencha-touch-2-localstorage-example/

How to organize my project?

I would like to create a project but i don't really know how to organize it and what do i exactly need.
I want an application which has a tableview ( grouped section ), with a refresh ( pull down ) of the framework three20, then when the user refresh the uitableview, the app check the webservice and ( i guess ) get the JSON and update the tableview ( by populate a plist ? )
so what do i need ?
a webservice, with a backfront where i can update my json ?
my application which has a plist populated by the json received from the webservice ?
AND
i have another view, where the user can send to the webservice information about him and update it when he wants. he will have in the application a page where he can see his information that he sent to the webservice earlier.
ps : should i use coredata ?
hope you get what i wanted.
Thanks guys !
You could use coredata, i find it organizes everything much better, but there is of course an associated overhead with using it. You should definitely use it when you will be editing the information you have stored, sounds like per your requirement even though you do store the data, once you edit it you send it back to the web service, so you are not really modifying your stored data.
Therefore a p list would work just fine, but again there is nothing wrong with storing it in core data. Your general idea is correct, you will be calling your web service, parsing the JSON or XML that you get and refreshing your table with the data.
Depending on what communication protocol (SOAP, REST) and the response (JSON, XML) the Web service is using there are tools that will generate all you need for the communication, you don't really need to do all that by yourself.

Display iPhone Core Data DB outside of app

Is there any way to display the content of an SQLite-Database (Created with core data) outside of your app?
Any DB-manager that can display it's data or any way of viewing the raw data in Xcode?
//OC
I've never used it, and from the command line I haven't been able to see all I wanted to see, but I lack the experience of DB interaction to rule that option out.
BUT, I've seen "Dr. Brad Larson" in a great tutorial about Core Data use an application call: "Base" that is available on the Mac AppStore. ( http://menial.co.uk/software/base/ )
Check out this Q/A: How view data stored in Core Data?
I second the recommendation of Base