sqlite and background services in Sencha Touch 2 - android

I am a newbie to Sencha Touch, and we need to build a cross platform mobile application which involves upsync and downsync of quite a large amount of data through REST Web Services as background servies in Sencha Touch and if internet is not available data has to be stored in local sqlite db and after connecting to internet, data has to be synced. I have googled it but didn't get enough information on this. Can someone please guide me how to achieve this?
Thanks in advance.

There is no direct way of using SQLite in Sencha Touch. However, you can indeed use Phonegap to achieve SQLite DB connection in your Sencha Touch application. This should be fairly easy to accomplish. You can also look into Localstorage or WebSQL feature in Sencha but I am not sure that suits your requirements.
Here are some helpful links:
http://hansjar.blogspot.in/2013/04/how-to-easily-add-prepopulated-sqlite.html
http://druckit.wordpress.com/2012/11/16/using-the-sencha-touch-2-1-sql-proxy/

1) I am a newbie to Sencha Touch, and we need to build a cross platform mobile application
You need to start with sencha docs and start building some simple application.
Learn Sencha Class System
In sencha framework folder there is a examples folder you can find many examples there, use that to start leaning and experiment with it.
2) which involves upsync and downsync of quite a large amount of data through REST Web Services as background servies in Sencha Touch
Then, You need to know some more specific concepts like Store and MVC Pattern
If you are not familiar with MVC then
MVC in Depth Part 1
MVC in Depth Part 2
Useful SO link
3) if internet is not available data has to be stored in local sqlite db and after connecting to internet, data has to be synced
I think there are two ways
1, If your going to use PhoneGap (i am using it), You can do it by using PhoneGap connection feature to check internet is available or not, if not then there are ways to store data in local sqlite db in sencha.
2, I think sencha touch itself has device connection check feature (i didn't use it yet) to check internet availability and if not then as i mentioned above you can use local sqlite db.
So start trying and if you got stuck post here. you will get help from me and my fellow SO users.

We are building the same kind of application. You will need to use Phone Gap to communicate with sqlite through Sencha Touch. But Sencha Touch store couldn't directly use phonegaps functions to insert/select data into/from sqlite. You will need to use sqlite storage proxy for store in Sencha Touch.

ST's built-in Ext.Connection.IsOnline() seemed a bit flaky to me (there are reports on the ST forums that it shows a connection when a phone is in airplane mode or when wifi is disabled on a pad; in my experience it seemed to be able to detect the presence or absence of an access point, but not whether the access point had Internet access), so I went with cordova (phonegap) for checking online status.
You could maybe also set a fairly aggressive timeout on your request and see if the response.status is 0 (though that doesn't necessarily mean you have no Internet connexion: http://www.w3.org/TR/XMLHttpRequest/#the-status-attribute
As for SQLite, I used shepsii's proxy (http://www.sencha.com/forum/showthread.php?195991) for some time with success on both iPad and Android. Having read that ST's Sqlite proxy is now stable in version 2.2.1, I recently switched to using that 'official' version. Whilst it works fine on an iPad, on my Android tablet the app now hangs at the loading screen. As yet I'm not sure if that's due to the proxy or to something daft that I've done, but be wary.
In my Win8 version of the app, I just used a bunch of JSON files which can be stored in the user's local or roaming storage. For my purposes it seemed to be quite easy to mimic SQL queries using that approach, so I'm thinking of adopting the same approach in ST. The only problem is that I don't know where to put the JSON files.

I have used the following plugin for Background and Timer Services.
https://github.com/Red-Folder/Cordova-Plugin-BackgroundService
and I have used phonegap api for accesing sqlite.
http://docs.phonegap.com/en/1.2.0/phonegap_storage_storage.md.html

Related

What is the proper structure for accessing a database on mobile apps?

I'm a complete beginner with mobile development. A friend of mine approached me with a project idea, asking me if it was possible to do it. The way I see it, it is a mobile app that needs to read and write data on a database in order to write inspection reports on the job of various staff members.
I told that friend that I would check how mobile development works first and would try to create a prototype to present. I've asked and Android is the main platform that is desired, so I've tried working with Android Studio and it is pretty straight forward up to now.
So, now I'm wondering what is the proper way to sync mobile apps with the database. Last time I worked with a database in a project we had multiple clients connecting to a server to play some small game together and the server would access the database and send the data back to the client through the network connection. So, I was wondering if a mobile app was supposed to use this communication structure or would simply talk directly to the database instead of a server.
The structure I have in mind:
Is this an acceptable structure? Or am I thinking of this the wrong way?

Database Compatibility: Building a database to support apps across multiple OSs

I know very little about developing apps/software, so please forgive my ignorance in advance.
I would like to develop a proprietary digital dictionary (using my own definitions, not taken them from other websites). To do this I will need to build a database, that will contain multiple definition for each words and many examples of their use.
Eventually, I would like to use this database to build apps for Android, iOS, and Microsoft operating systems. My question is, for example, if i use SQL Server 2012 will I be able to use this same database when I try to make an app for Android? If not are their any neutral open source database systems like XAMPP which would work across all three operating systems?
Extra Information: I would like the apps to pull definition from a database embedded inside the app, not from an internet server; this way, users will be able to use the dictionary without an internet connection.
Yes and no.
SQL Server works exceptionally well with ASP.NET, and with ASP, you can write a webservice to grab the data off the server and deliver it to ANY platform in a readable format (XML, JSON, or whatever).
Getting data from the server would then be simply a matter of consuming the webservice from whatever platform. Any of the mobile devices, any desktop implementation you decide to make, or even if you just gave your webservice a web page so the webservice could be consumed by browsing to a web address.
From there, all you need to do to make the data accessible offline is to setup the application to download the entire database the first time and store it locally (and from here, you could simply use sqlite). From then on, it could simply look for updates. Keep in mind, however, mobile devices have limited storage capacity.
If you want a common database that can be embedded locally in your app, as opposed to accessing a remote database, then SQLite is probably a good choice. It is fully supported in iOS and Android. It has a C API as well as others so it should also work with other mobile environments.

Android - Connect to MSSQL online database

I'm new to Android programming. I have a website with sql 2008 db, and now i would like to give the users the ability to use their smart phones to enter data to this db.
I was wondering what is the best way to establish it. Since I'm new to it I don't want to build something that's not so professional.
Thanks for your help.
If I were you I would consider two following options:
Have a web application optimised for mobile use;
Pros:
Updates are delivered immediately, as there's no client application, everything is done on the server;
Web application can be used on many devices with a browser and not just Android: iPhone, Blackberry, PC, Mac, etc.;
Cons:
Users need to be online to work with the application;
You can not leverage from the native UI components available to native device applications;
Write Android application that will work with the database via a number of REST endpoints exposed through a web application (again);
The pros and cons are a full reverse of what you had in the first option.
The right answer for me was to use KSoap library. I'ts very easy and works very well.
Here is a tutorial that will show you how to do it step by step.
http://java.dzone.com/articles/invoke-webservices-android

Access a local sqlite database on the android itself from a PhoneGap App

I know my question eventually won't match the title I opted for the question, but I honestly didn't know how to put it as I'm new to the Android and PhoneGap environments. If this is not a programming related question please accept my apologies.
We have got a .NET application that sends TASKS to our mobile employees' netbooks via webservice. The mobile users have got a local database that gets updated with new TASKS once they login. When the TASKS are completed, the local database gets updated. If there is a stable internet connection the update is then sent to the remote database.
Now we are planning to do both Android and iPhone version of the application. I understand this is possible using PhoneGap and HTML-CSS-JavaScript, but don't know how to go about it.
If anyone has experience of implementing these sort of applications, please guide me to some links/articles. I did some search on Google but didn't get a precise answer.
Thank You.
The getting started guides are all here. Each platform requires some amount of setup because of platform-specific SDK's and so forth you must download, so I would suggest starting with iOS if you have an iPhone or Android if you have an Android phone and then once you're up and running making the switch to developing for both simultaneously.
As for the question about a SQLite database, PhoneGap should be able to do what you describe. The documents for local storage, once you get to that point, are here.

CouchDB Replication to Android ... for Android Applications, or Android Browser or?

My goal is to replicate my CouchDB to Android to allow offline access & reduced latency.
I watched this video:
http://www.youtube.com/watch?v=3RdcKWYGqig
One fundamental point I don't get is:
Does CouchDB replication work only
for Android Applications?
Or, can it work for a web application
running in the Android browser (this
is what I am shooting for)? If so, how?
you would need to install the CouchDB software on the Android device in order to get it to work.
Once that is installed, the user can visit your app via the browser at http://localhost:5984/path/to/my/app
You could create one of those bookmarks that looks like an app, and point it to the local couch url.
Chris
Ofcourse you can create browser based applications.
Either try creating a couchapp and loading it with the browserview in android or club it with something like Sencha to wrap it around and making it a hybrid native web app!
If you know how to create couchapps, then it should be pretty straight forward, else, take a look into how to create simple couchapps. Ofcourse, i'm going under the assumption that you already know a bit of Android!

Categories

Resources