Saving GameState on Android JSB?

Saving GameState on Android JSB?
0.0 0


I’m making my game in JS Binding on Android and I wanted to save the game state, like a NSUserDefaults. Anyone know how I could do this on Android JS Bindings?

Thank you in advance!


It will be done in next release, we will bind sqlite to save userdata.


good news about this.


So @Chen, it was done![](?

I am trying to use cc.UserDefault, but been unable until now…

Should I use some other class?



For anyone interested I manage to solve it by using the expressions:




Not sure why the cc.UserDefault do not works since this works good.


so, we couldn’t use cc.UserDefault? why?


@Pedro Kayatt

Can you tell me how you achieved that?


Amit Hooda wrote:

@Pedro Kayatt
Can you tell me how you achieved that?

Sorry, but I kind of missed the point here…

As I said, sys.localStorage.getItem(“mItem”) returns the value that was previously set by:
sys.localStorage.setItem(“mItem”, value)…

Are you talking about something else?


@Pedro Kayatt

Yes i know how to use getItem and setItem functions but what if i need to add more functions like getItem so that i can do much more than just key values pairs?


In that case you must configure to use some SQL Options, it is not that simple and unfortunately I never did.

Maybe it is good to open up another thread, since you don’t want to save the GameState you want persist complex data, as for my understand…

Be well,


Works but every update of the app the local storage is wiped out.

How can I save user data which survives app updates ?