0

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.

Ashok
  • 1,251
  • 11
  • 19

5 Answers5

1

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/

GenieWanted
  • 4,473
  • 4
  • 24
  • 35
  • Hi Geeniewanted, Thanks for your response, the first link is for prepopulated SQLite DB, but we have to create the sqlite db in our app and need to run the sql commands on the created sqlite db, can you please share any ideas on this. Thanks once again. – Ashok Jun 13 '13 at 08:06
  • Ah.. Okay.. You can refer this link to get started on creating a table within your app. https://gist.github.com/edwardtoday/2204864 This one shows creating a table with Phonegap + Jquery Mobile. But, you can actually replace Jquery Mobile with Sencha in place. Wishes!! – GenieWanted Jun 13 '13 at 08:19
  • 1
    http://luthfihariz.wordpress.com/2011/10/23/android-sqlite-phonegap-jquerymobile/ This one too! – GenieWanted Jun 13 '13 at 08:21
0

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.

Community
  • 1
  • 1
Viswa
  • 3,211
  • 5
  • 34
  • 65
  • Thanks for the response Viswa, I'll surely consider the above resources and will post here. and one more thing I want to know does Sencha support android services? have you ever used the android servies in Sencha or by using PhoneGap... I am badly require those services, and Thank You Once Again :) – Ashok Jun 13 '13 at 07:56
  • What are the android services you talking about ? – Viswa Jun 13 '13 at 10:07
  • http://developer.android.com/guide/components/services.html This is the one I want to achieve in Sencha Touch 2. Because we need to run lot of sql queries in local sqlite db (and REST Web Services if internet is available) for the first time when user login to the application. This should not impact the UI Thread – Ashok Jun 13 '13 at 12:31
0

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

Ashok
  • 1,251
  • 11
  • 19
0

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.

Vaibhav Vidhate
  • 186
  • 1
  • 5
0

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.

munder
  • 137
  • 1
  • 12