HI,
I am using sqlite3 for wP8, the database was created successfully, but when the application quit, the database file did not save to local storage.
The code:
result = sqlite3_open_v2(“Test.db”, &pDB, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL );//create database
sqlite3_exec(pDB, “PRAGMA synchronous=ON”, NULL, NULL, &errMsg);//force to sync to local storage
…
….create table
….insert data
…
sqlite3_close(pDB);
Please advise.
Hi, Eric Hung
Help me plase, you can using sqlite3 in windows phone 8?
How to use sqlite in windows phone 8?
http://www.cocos2d-x.org/boards/6/topics/24744
It Work
I Create Class Database
Ex.
`#include “Database.h”
Database *db = new Database("DBCT.db"); && Database *db = new Database(); db->open("DBCT.db");
db->query("CREATE TABLE IF NOT EXISTS dbct( id_ct INTEGER PRIMARY KEY, score_ct INTEGER NOT NULL, time_ct VARCHAR(10) NOT NULL, day_ct VARCHAR(10) NOT NULL)");
db->query("INSERT INTO dbct(score_ct, time_ct, day_ct) VALUES (1234, 'test1time', 'test1day')");
db->query("INSERT INTO dbct(score_ct, time_ct, day_ct) VALUES (764, 'test2time', 'test2day')");
db->query("INSERT INTO dbct(score_ct, time_ct, day_ct) VALUES (1500, 'test3time', 'test3day')");
vector<vector<string> > result = db->query("SELECT score_ct, time_ct, day_ct FROM dbct ORDER BY score_ct DESC LIMIT 5");
for(vector<vector<string> >::iterator it = result.begin(); it < result.end(); ++it) {
vector<string> row = *it;
string score_ct = row.at(0);
string time_ct = row.at(1);
string day_ct = row.at(2);
CCLog("Score : %s, Time : %s, Day : %s", score_ct.c_str(), time_ct.c_str(), day_ct.c_str());
}
db->close();`