I’m a newbie in Cocos2d-x. How can I store the database? Which database can support all platforms (android, ios, windows phone, win32, web, etc)?
It’s very nice if you can give me a detail tutorial or examples to use database in Cocos2d-x.
you can use sqlite and wrapper for it if you don’t like C API.Wrapper: easySQLite.
You can use any database engine it only must be in C/C*+ cocos2dx gives you path where you can save your database.So please don;t search about database for cocos2dx simply look for database libs in C/C*+
I suggest you to use SQLite because this is most popular and also in 1 file. Also cocos has it in extensions path?
Yes, sqlite3 is in external folder of cocos2d-x.
Great, thank you so much. I’ll try with Sqlite3
If you just want to store values in a persistent way, you are able to use sharedUserDefaulthttp://www.cocos2d-x.org/reference/native-cpp/V2.2.1/d0/d79/classcocos2d\_1\_1\_c\_c\_user\_default.html\#ad25d8b663ab8c114c73ea876dc7b3846
Example usage:set:CCUserDefault::sharedUserDefault()->setIntegerForKey("localGamesLost", 0);get with default value if the key do not exist:CCUserDefault::sharedUserDefault()->getIntegerForKey("localGamesLost", 0);
UserDefault is simple but not a good way to save game data.Sqlite3 is better
sqlite3 is very easy to use and you can add encryption, read-only db, compression, etc.
transactions, pre-compiled procedures, strongly typed data, metadata … etc…
Regarding the encryption…For encryption you have to use a key, where or how do you store it in a secure way?
I hope I can help u in this topichttp://www.cocos2d-x.org/forums/6/topics/42201
Thank you so much
yuye liu wrote: