Ok, here another problem encountered in studing SDK for wearable.
How to manage databases?
I mean: I studied the SDK help and tried to implement an IndexedDB. But, as for other APIs, tutorials and examples are absolutely not detailed.
I created a DB, a store, putted data in it, but don't understand how to read data back! This is what the SDK example says:
var request = tizenStore.put(data); request.onsuccess = function(e) { tizenDB.db.objectStoreId = request.result; var data = tizenStore.get(tizenDB.db.objectStoreId); };
supposed tizenStore is the object store, and the (first) data variable something simple like:
var data = { "key": new Date().getTime(), "text": "Tizen-" + Math.random() };
Yes: with the tizenStore.get I have access to my data but ... this function has an output of the inserting process, as a parameter!
In other words: if I haven't the request variable, this means I haven't a tizenDB.db.objectStoreId, too! I tried something from the HTML5 help site, too, but it still doesn't work:
var txn = db.transaction(); if (txn) { var store = txn.objectStore(objName); if (store) { var cursorReq = store.openCursor(); cursorReq.onsuccess = function (ev1) { var cur = ev1.result; if(cur) cursor_get_record(cur, txn, objName); } cursorReq.onerror = function (ev1) { output_trace("Failed to open cursor. Error: " + ev.message); } } } function cursor_get_record(cur, txn, ojName) { var moveReq = cur.move(); moveReq.onsuccess = function (ev) { if (ev.result) { PrintRecord(ojName, cur.value); cursor_get_record(cur, txn, ojName); } else { //no more record txn.commit(); } } }
It seems that the store.openCursor() didn't fire any event...
Any ideas? Thank you :)