View Full Version : [FIXED] Localstorage not working in native iOS or native Android application

11 Apr 2012, 7:18 AM

Ext version tested:

Sencha Touch 2.0.0
Browser versions tested against:

Native app
DOCTYPE tested against:


Localstorage doesn't seem to work when using it in a native iOS or Android application
Its works fine when running in a browser on all OS.
Steps to reproduce the problem:

Run the included code and restart the application several times
The result that was expected:

First time message : Number of items loaded : 0, Number of items saved : 1
Message second run : Number of items loaded : 1, Number of items saved : 1
The result that occurs instead:

First time message : Number of items loaded : 0, Number of items saved : 1
Message second run : Number of items loaded : 0, Number of items saved : 1
Test Case:

name: 'TestApp',

launch: function() {

Ext.define('TestModel', {
extend: 'Ext.data.Model',
fields: [
{name : 'field1', type: 'string'}

Ext.define('TestStore', {
extend: 'Ext.data.Store',
requires: [
storeId: 'TestStore',
model: 'TestModel',

type: 'localstorage',
id: 'mysettings'

var store = Ext.create('TestStore');

var nrloaded = store.data.items.length;



var nrsaved = store.data.items.length;

'Number of items loaded : ' + nrloaded + ' <br /> Number of items saved : ' + nrsaved


See this URL for live test case:

Possible fix:

not provided
Additional CSS used:

only default ext-all.css
custom css (include details)
Operating System:

iOS 5.1
Android (all versions)

Jamie Avins
11 Apr 2012, 8:49 AM
Thank you for the report.

11 Apr 2012, 11:53 PM
Will the fix be in 2.0.1 or 2.1?

Please add a localstorage example to your delivered examples so critical bugs like this maybe found earlier and developers can learn how to use localstorage.
(good example using localstorage:
http://miamicoder.com/2012/how-to-create-a-sencha-touch-2-app-part-3/ )

You have almost 30 examples but none of them uses a localstorage-proxy!!!

19 Apr 2012, 3:09 AM
Can this bug be resolved by using phonegap 1.6 or only by upgrading to 2.0.1 final / 2.1?

19 Apr 2012, 3:20 AM
I am also looking for a solution to this problem.

Jamie Avins
19 Apr 2012, 7:22 AM
Can this bug be resolved by using phonegap 1.6 or only by upgrading to 2.0.1 final / 2.1?

PhoneGap is also struggling with the issue.

Rui Marinho
21 Apr 2012, 4:14 PM
Cordova 1.6.1 fixes this issue.

24 Apr 2012, 2:07 AM
Does anyone found a fix for this? I would prefer to work only with the sdk tools, not to package with phonegap

24 Apr 2012, 3:06 AM
I'm also still waiting for the sencha team to fix this.

As far as I can see, the only fix now is using phonegap.

I also prefer not to use phonegap for this.

Can anyone in the sencha team give us more information about this ?
Is this going to be fixed in a near release ?
Is there a workaround ?

24 Apr 2012, 10:44 PM
This bug is not mentioned in the release notes for 2.0.1 final.
Does this mean it's still there ?

Jamie Avins
25 Apr 2012, 8:33 AM
This has not been addressed yet.

26 Apr 2012, 3:41 AM
Found a workaround for localstorage on native iOS application : use cookies.

The bad thing is that cookies don't work either on an Android packaged application.

I found a lot of workarounds on the Internet, but al of them are meant to be implemented in Java.
So could it be that the Sencha team has to adapt their native Android wrapper to allow this ?

26 Apr 2012, 3:49 AM
Why do you not use Phonegap / Cordova?

They have a much better support for localstorage, filesystem und SQLite and are faster fixing bugs.

26 Apr 2012, 3:54 AM
Because using Phonegap requires a Mac to package for iOS.

And with the sencha packaging I can do everything from my windows workstation, without buying a Mac.

I see they use Nimblekit to package.

Gonna have a look over there to see if I find a solution

26 Apr 2012, 4:01 AM
Even better : Sencha purchased Nimblekit :)

26 Apr 2012, 4:58 AM
PhoneGap offers a cloud based build service.

Does https://build.phonegap.com/ work if you include Sencha Touch?

4 May 2012, 9:17 AM
I have run into the same issue when testing my app on Android, localstorage is reset when you restart the application.

On iOS what I find is even though the cache can clear it, the localstorage does persist for some time, but on Android it vanishes every restart which is really a pain as I am using it to store some login credentials like site name and user name which now have to be entered every time on a mobile which is just not easy.

Would be good to understand when a fix is possible for this using the native sencha packager.


4 May 2012, 9:20 AM
Is the current workaround to use phonegap/cordova and not the sencha packager or are there any other ways we can persist information (do not want to use cookies).


8 May 2012, 5:32 AM
While I understand there are issues with iOS, this is supposed to work on Android with Webview.

Is there any way this can get fixed on top of 2.0.1 with Sencha packager so that apps can be published. Right now I have this and the launch screen as the only last two things to fix to publish the android version of my app. It would be a pain if I had to now go over to PhoneGap 1.7 and continue for Android, got so much support in getting the iOS version done and getting past the publishing issues, really asking for help here in getting this done, and in the process getting Sencha to work for native app publishing.


Rui Marinho
8 May 2012, 6:15 AM
The silence from the sencha team is terrible...


8 May 2012, 6:20 AM
The problem seems to be in the native wrapper.
I think they use Nimblekit for this.

They just purchased Nimblekit, so I think they can find a solution.
But maybe it's all still a little bit new for them.

8 May 2012, 11:29 AM
Hello all, in the closest couple days it will be fixed and released

8 May 2012, 12:14 PM
Thanks Alex - we were just discussing this issue at SourceDevCon in London last week - looked like we were going to have to revert back to cookies or experiment with SQLite - but good news to hear that you appear to be working on a real solution :)

8 May 2012, 10:32 PM
For iOs, I reverted to cookies.
And that worked without a problem, in the browser and as a native app.

But for Android, cookies don't work when packaging as a native app.

Nice to see the Sencha team is working on it.
They made a fantastic framework in very little time.
Keep up the good work !

13 May 2012, 7:10 AM
I am considering changing to Sencha, but I need the use of localstorage on iOS and Android.
So I am very interested in the fix of this bug.

How do I know when the fix mentioned by Voloshyn 8th May 2012,is available?

14 May 2012, 5:01 AM
I was literally just about to start developing on phonegap! So can someone at Sencha please please please clarify for me if this fix will also keep sqlite data persistent?

Many thanks, literally, if you can get a speedy response for me! As otherwise I'll start phonegapping and that would be time wasted if I could do it all from Sencha packaging

15 May 2012, 1:43 AM
Any updates on when this will be fixed - for Android (and if we are luck for iOS :-))

15 May 2012, 12:29 PM
This is the longest "closest" couple of days I've ever seen! Guys, you do a fantastic job on this framework, and I really mean that, but don't post stuff like that if you're not going to come through. It's just wasting time for us. And I'm sure more time will now be wasted when I try to go off phonegapping only to discover a week later that you finally post a fix here!

20 May 2012, 12:01 AM
Any news?

Rui Marinho
20 May 2012, 4:37 PM
"Real artists ship!"

come one guys..

21 May 2012, 3:08 PM
It's fixed on iOS for some time already, but I can't reproduce it on Android whatever I do, here is iOS build: http://dl.dropbox.com/u/8793605/stbuild.pkg but for Android it's not enough information to reproduce because it works fine with the given info.

21 May 2012, 10:32 PM
So you're saying :

You take the code of the application in the first post of this thread
You package it into a native Android application
After the second run the message shown is : Number of items loaded : 1, Number of items saved : 1

21 May 2012, 10:35 PM

I had the issue not with the web app as localstorage worked in this case. Localstorage did not work when the same app was packaged as a native android app. I just want to confirm this was tested, will test mine again with the latest build tool.


21 May 2012, 11:04 PM
No, I'm native obj-c/java programmer and I do backend, not javascript frontend, so I took localstorage example I have (not your code as I don't know if it's correct or not) and checked different parameters within webview, with all parameters sample project is working, here is sample project, it works: http://dl.dropbox.com/u/8793605/localstorage.zip try to package it and see if it works for you

21 May 2012, 11:10 PM
I will involve ST front end developers to investigate this

22 May 2012, 1:40 AM
Also it would really help if you could provide some insight into how this is being solved on iOS. If the html localstorage is not being used, what is being used now and what if any are the issues/limitations of what is being done for iOS.


22 May 2012, 1:55 AM
Did you only fix the Sencha bug or is localstorage now persistent after iOS 5.01 Update, like the phonegap fix https://issues.apache.org/jira/browse/CB-330

22 May 2012, 2:18 AM
Also... does this mean sqlite is persistent if I native package using Sencha command?

22 May 2012, 8:16 AM
we just backup local storage on application quit and restore it on application launch, that's the fix for iOS.

>>does this mean sqlite is persistent
localstorage is persistant, sqlite is not supported yet

23 May 2012, 10:53 PM
The backup of localstorage just on quit/exit will not work as most apps on iOS only get suspended. If there is a cache cleanup when the application is running or when it is suspended, all data stored in localstorage will vanish. Since I cannot see the details, wanted to check if these use cases handled?

What I do is store authentication credentials in local storage at login and when the app is launched again to get this and save the user the pain of typing this again. It is better to have a method to explicity backup information or tie it to one of the store proxy events.

23 May 2012, 11:10 PM
when application moved to background we backup localstorage too, and restore when app comes to foreground

23 May 2012, 11:13 PM
Thank you for the clarification.

24 May 2012, 1:03 AM
1. Installed the latest build tool
2. Use app with local storage and stored data
3. Killed app
4. Restart app, does not get any data from local storage
5. Works when using localstorage directly by running the same app as a browser app on android

I need to get this working as I persist auth credentials for the app in localstorage to avoid users re-entering this each time. Can you investigate this with the example given at the beginning of the thread to see why in the native app localstorage is not working on Android.


24 May 2012, 1:07 AM

thank you for testing this.
I can't test it, because I think the latest build is only for Mac and I don't own one.

24 May 2012, 8:33 AM
did you try the example I provided? http://dl.dropbox.com/u/8793605/localstorage.zip

24 May 2012, 10:04 PM
Yes finally got the very simple localstorage to work on Android 4.0.3 as a native app, the problem is not with this case but a more complex case using localstorage with a model, and that works in the desktop browser, in the browser on the android mobile, but not in the native application. I have created a sample that does not work and will share it now.

24 May 2012, 10:27 PM
Unzip and build this application. You will have to copy over the sdk directory into this app as I did not zip it up to save space.


Then in the application there are three new buttons extending the dropbox example to a little more complex example where there is a model which is being stored in localstorage and has uuid based identifiers.

Init Store - sets up store and model
Load Store - to load from store
Save Store - to save to store

1. Launch application
2. Click on Init Store
3. Click on Save Store (will save variables to local storage)
4. Exit application (kill it)
5. Launch application
6. Click on Init Store
7. Click on Load Store

Result: no records are loaded in Android native application

If the same app is run in Chrome on the desktop or in the 4.0.3 browser the Load shows the stored results. This also works properly in iOS as long as localstorage is not cleaned up.

I did some further testing by printing out all localstorage data and did find it is just missing on the phone after an exit and re-launch. The following type of code was added to print the results of localstorage

var localString = "";
for (var key in localStorage) {
localString += "key: " + key + "value = " + localStorage[key] + ";";

Ext.getCmp("output").setHtml("Init Store: done<br><br>Local Storage: " + localString);

6 Jun 2012, 6:28 PM
Could you please let us know the results of investigation the local storage case, currently not able to make it work on Android and have uploaded test case. This is blocking my application and has blocked it for a long time. I assume this must be a critical case to make the packaging process work for Android and would be needed for anyone publishing apps using the build framework, so let me know what can be done.


11 Jun 2012, 1:52 AM
Any updates on this, my Android app is just stuck due to this and I desperately need to update the one in the store with a new one, and need local storage to work.


11 Jun 2012, 10:18 AM
Had anyone successfully used Phonegap to address this or is there any update? Like the other comments here, I'd prefer not to go there (haven't used Phonegap for anything yet), but local storage is an important part of my app and I was hoping to publish native versions.

13 Jun 2012, 6:11 AM
It is a bit frustrating having a one way conversation about an important bug. Do let me know how I can get this addressed to package the Android app's as that is blocked. If I need to join support and file a support incident I can do that, if there is something else I must do ... at least let me know how I go about getting help.

I have built the app, and have deployed to the iOS store using Sencha packager and want to do the same for the Android app, and need help in getting this done. I am not sure if anyone else can publish an app if critical things like localstorage are broken, so I have to assume this is in the interest of Sencha to get fixed, and this end to end process testing is a really good test for the Sencha packager ..

At this point a frustrated developer stuck on Sencha touch :-(


13 Jun 2012, 9:59 AM
I am taking a look into this issue now-

13 Jun 2012, 1:46 PM
we fixed the problem, please install latest stbuild from here: http://dl.dropbox.com/u/8793605/stbuild.pkg

13 Jun 2012, 2:09 PM
Hi Volyshyn,

I'm not clear as to how to 'install a .pkg' on windows.

Could you give me some quick instructions or links which explain how to apply the stbuild.pkg you refer to?

14 Jun 2012, 12:20 AM
Thank you very much for solving this issue, local storage persistence works with the new build, and this I hope is the last of my issues to finally finish testing of the app to push it into the store. So now I am past all known bugs and lots of testing, the only thing I have not tested is the final push to the app store.


16 Jun 2012, 3:05 AM
Just to close this issue, was able to use version 2.0.1 of Sencha Touch with the new build tool, test and publish my app to the Google Play store.


Thank you for your help and support in getting to this milestone of building the app on ST 2.0, and using Sencha packager and publishing to both the Apple and Google stores a native app (no using Xcode, no PhoneGap, and very nice command line builds did make it easy and simple to build, test, and deploy the app)


16 Jun 2012, 8:02 PM
Spoke too soon :-(

This is a regression from sencha command v2.0.2 (SDK tools Beta 3) - which I tested just now and creates a native app just fine, but does not have the localstorage fix for iOS for me to publish my app.

Right now with the latest build tool, and on my machine with the latest version of Xcode the built app is not honoring orientation changes. When I rotate the phone the app does not change from portrait to landscape and the same issue happens on the iPad (used to work before). The same app when called from Safari in the simulator/phone honors orientation changes - so nothing to with the app, but with the building and packaging to a native iOS app. I did try to go to the pervious version of the build tool which had the fixes for iOS local storage and found the same behavior.

The packager.json has the orientation details

* @cfg orientations
* @required
* This is orientations that this application can run.
"orientations": [

and the generated Info.plist has the orientation details



Did a diff of the Info.plist with my published iOS app that works well with the current one and found only version number is different, nothing else.

17 Jun 2012, 11:58 AM
Thank you very much. I start post in march about this problem with android localstorage and this stbuild solve it. Good job

17 Jun 2012, 11:28 PM
The manifest needs to have the telephony required as false to not filter out tablets like Galaxy Tab 10.1

<uses-feature android:name="android.hardware.telephony" android:required="false"/>

I am just clubbing this with the previous issues and in the same thread as this is a custom build of the application. Did file a general question in the Sencha forums, but it looks like the answer requires a fix to the stbuild tool


Would really again appreciate if the iOS rotation fix and this fix can be provided as part of an updated built tool to make the app work on both stores (these fixes are needed for all Sencha developers)


20 Jun 2012, 6:17 AM
The issues with the localstorage fix build for iOS and Android.

1. iOS - device rotation does not work
2. Android - tablet support does not work (likely due to telephony requirement)

These are blockers and I have some users who are really pushing me on the support for Android tablets, and I need to update for iOS to fix the existing issue. So while the localstorage issue has been fixed the build tool is not effective till these two issues are fixed to deliver a Sencha app to iPhone, iPad, Android phone and Android tablet.

Please help in getting this addressed in the build tool so I can publish and be done ... I am sure every Sencha developer who has to publish a native app needs these fixed else the framework does not help in getting the end to end process working to completion.


23 Jun 2012, 6:00 AM
Hi Voloshyn,

I'm also facing the localstorage persistence problem and I'm using windows to build the android apps. So, can you please release stbuild.msi for windows. Thanks you very much.


24 Jun 2012, 10:26 PM
Sencha native app does not work on android tablets, and with this build iOS tablets are also not working due to the screen rotation issue. Fixing localstorage and making it work on devices including tablets I would assume is important, and this should help in getting the build into better shape ...

Any chances of getting this fix ...


25 Jun 2012, 12:15 AM
No news?

26 Jun 2012, 6:17 AM
I am losing confidence in the whole Sencha native building stuff with each and every day. How can I support an app for Android and iOS if the framework developers need more than 4 weeks to provide build tools that fix errors but do not cause new problems?

26 Jun 2012, 6:30 AM
Just use phonegap build guys. It gets the job done and you know adobe are going to react quickly to any iOS changes brought in. It's been months now since this change and Sencha's still struggling. Phonegap had a fix in days. It's clear the focus here is on web apps; the wider question is obviously whether Sencha Touch apps are even workable performance-wise as native apps.

26 Jun 2012, 11:27 PM
Yes but Sencha is not mean to be used with Phonegap.

Native Packaging

http://docs.sencha.com/touch/2-0/guides/native_packaging/icon.pngWeb applications work everywhere. But there are still a few features uniquely available to native apps — like camera access and app store distribution — that are essential to app developers. Sencha SDK Tools give you the best of both worlds, providing a way to seamlessly “wrap” your web app in a native shell. Whether you’re on Mac or Windows, you’re one command away from deploying to the Apple App Store or Android Market.

Source: http://www.sencha.com/products/touch/ and http://www.sencha.com/products/touch/features/

26 Jun 2012, 11:30 PM
Yes I can't get it to work with the phonegap.js file, I'm lucky enough not to need camera/accelerometer access.

26 Jun 2012, 11:35 PM
Yes but Sencha is not mean to be used with Phonegap.

Source: http://www.sencha.com/products/touch/ and http://www.sencha.com/products/touch/features/

If it is not meant to be used with phonegap, why are there references to phonegap in Ext.device?

26 Jun 2012, 11:39 PM
Sencha needs a much faster/shorter release cycle in regards of bugs fixing.

Sencha Touch 2.0 came out March 06, 2012 and only had one (working) bug fixing release ( which solved 8 bugs:

Sencha gives no dates on the next Release (2.0.2).

Maybe they are in big trouble because Ed Spencer, one of the main devs, left short ago: https://twitter.com/edspencer/status/213743181093797888
Or they are getting to big (>100 employees). If they give no info, we can only guess and expect the worst.

Maybe Adobe should buy Sencha and integrate Sencha Touch with Phonegap. Phonegaps bug fixing releases are published every four weeks.

27 Jun 2012, 12:29 AM
+1! (I cannot post vote anymore.)

Thanks for this information, good summary! Sure we're in trouble!

We need:
Faster/shorter release cycle
Public road map with dates (for releases and bugs, even if it's only estimations)
Advanced and working examples from the Sencha Team
Advanced, clear, synthetic and working documentation from the Sencha Team
Improvements in the Sencha Architect IDE (Nearly unusable, very bad to learn!)
+Good practices guide
Not sure someone wanna buy Sencha :))

27 Jun 2012, 12:34 AM
I think it's all just a little rushed out to be honest and Sencha are working towards loads of other stuff before the released products are working. Sencha I/O can wait - can we get Sencha Touch 2 actually working properly first please! This bug and the filter function bug are a joke.

mcbl hit the nail on the head. It's communication that's the problem. If Sencha are understaffed, and can't get these fixes out on time, at least let us know. Developers invest time and energy into Sencha and really appreciate the great framework. At the same time we're held to deadlines and if we have no timescales for fixes it makes our lives very difficult.

29 Jun 2012, 7:50 PM
Did file a support issue on this one and it looks like this will be addressed in 2.0.2 when it comes out.

1 Jul 2012, 11:23 PM
Don't rely on their promises. Do you have a date? :))

7 Jul 2012, 9:04 AM
Local storage bug was fixed for both windows and mac packagers in SDK tools 2.0.2, available to support subscribers soon.

Sencha native app does not work on android tablets
Some permissions for Android phones aren't compatible with Android tablets, that's why it's not working, we are making changes to fix that

10 Jul 2012, 4:23 AM
When do you expect to rollout the SDK tools 2.0.2 ? Our project is getting stuck at this moment...

Local storage bug was fixed for both windows and mac packagers in SDK tools 2.0.2, available to support subscribers soon.

Some permissions for Android phones aren't compatible with Android tablets, that's why it's not working, we are making changes to fix that

19 Jul 2012, 6:41 AM
I am faceing the same issue. is there any update?

19 Jul 2012, 6:52 AM
Having now successfully built my apps to native using phonegap with very few issues, I can fully recommend that route ... I haven't had any compatibility issues. Sencha can't be trusted for quick fixes and this is an area where quick fixes can be in desperate need at times as iOS 5.1 showed!

20 Jul 2012, 6:48 AM
Am close to needing to publishing a new app, and existing app is just waiting for this for a fix/update. Any dates on when this is ... 1 week, 1 month, 3 months, ... or more ... there must be a better way to support the dev community, if you tell me more than a month out I will change and spend the time to get phonegap working, just tell us an approx timeframe, we all know how software projects work and how sometimes things push back, but not communicating any timeframe is not good.

Sencha touch is an amazing product, but timely support is a killer feature which if not there for the dev community will drive developers to other solutions over time.


26 Jul 2012, 6:24 AM
Having now successfully built my apps to native using phonegap with very few issues, I can fully recommend that route ... I haven't had any compatibility issues. Sencha can't be trusted for quick fixes and this is an area where quick fixes can be in desperate need at times as iOS 5.1 showed!

I know this isn't exactly the place for this, but what modifications did you have to make to get localstorage to use PhoneGap? I'm already including PhoneGap in my application, but I'm using Sencha's localstorage proxy to read/save some data and I don't have the option of upgrading to the beta sdk tools build. Does PhoneGap automatically intervene with localstorage if it's loaded?

26 Jul 2012, 6:25 AM
Yep. Just package and go and you're done. I really don't understand why sencha do all this native stuff when phonegap have already got it so well done.

26 Jul 2012, 6:59 AM
Yep. Just package and go and you're done. I really don't understand why sencha do all this native stuff when phonegap have already got it so well done.

Because competition breeds success my friend!

Also, I forgot to mention, I'm primarily using build.phonegap.com to build out the app (best option when using Windows imo), but it still takes over right? Just want to make sure I've got all the bases covered.

14 Aug 2012, 4:29 AM
Any news on this bug? I'm using sencha-touch- and the localstorage is not persistent when packaged as native app.

14 Aug 2012, 5:48 AM
I moved to using phonegap 2.0 for iOS and Android, took a day to move over and you get all the flexibility and so far have not run into any issues. That would be the way to get around this issue.

14 Aug 2012, 6:08 AM
4 months and >9.000 views later and still open and no dates.

This bug is not marked as fixed in the 2.1 beta release notes yet:

14 Aug 2012, 6:33 AM
Good news: I have implemented the code in the link below, it fixed the problem and is in our production release.

The bad news: it is a native application fix. I copy the code right into my AppDelegate.m


29 Aug 2012, 2:03 AM
This is the solution to the problem.

Android stores local storage based on concept of shared preferences which is supported for API level >7. In packager.json the API level is 7 changing this value(e.g.: 16) and using sencha command to package the app would throw an error asking you to check the android list targets.

This issue arises because you do not have the corresponding OS image for the list target. If you are using API level 16; then download Android 4.1 OS image using SDK manager. Then package the app & local storage would work fine...

30 Aug 2012, 11:22 AM
It took Sencha AGES to sort this one out (assuming that it is indeed sorted out). I spent time on the Phonegap forums and you could see the Phonegap developers wrestling over the issue over a few days and try out different solutions before they eventually found a fix.

I don't see why Sencha's developers don't spend time on the Phonegap forums and get ideas for fixes. The Phonegap team is really really efficient (although admittedly larger) and it's for everybody's benefit if solutions and ideas are shared.

What's the point of open source if there's no shared source or knowledge?!