アプリを作成し、そのデータをローカルの tizen モバイルに保存する必要があります。これは私が書いたコードです:
<script type="text/javascript">
function saveData() {
var a = document.getElementById('star');
var b = document.getElementById('checkone');
var c = document.getElementById('note');
var d = document.getElementById('med');
var e = document.getElementById('checktwo');
var f = document.getElementById('wgt');
var g = document.getElementById('wgt1');
/* localStorage.getItem("a");
localStorage.getItem("b");
localStorage.getItem("c");
localStorage.getItem("d");
localStorage.getItem("e");
localStorage.getItem("f");
localStorage.getItem("g"); */
/* Set the local storage item */
if ("localStorage" in window) {
localStorage.setItem(a, star);
localStorage.setItem(b, checkone);
localStorage.setItem(c, note);
localStorage.setItem(d, med);
localStorage.setItem(e, checktwo);
localStorage.setItem(f, wgt);
localStorage.setItem(g, wgt1);
location.reload();
alert("Date got")
} else {
alert("no localStorage in window");
}
/* Set the session storage item */
if ("sessionStorage" in window) {
sessionStorage.setItem(a, star);
sessionStorage.setItem(b, checkone);
sessionStorage.setItem(c, note);
sessionStorage.setItem(d, med);
sessionStorage.setItem(e, checktwo);
sessionStorage.setItem(f, wgt);
sessionStorage.setItem(g, wgt1);
location.reload();
alert("Data has been set")
} else {
alert("no sessionStorage in window");
}
window.onload = function() {
var localhtml = "";
var sessionhtml = "";
/* Get the local storage item */
for (var i = 0; i < localStorage.length; i++) {
localhtml += "<li>" + localStorage.key(i) + " : "
+ localStorage.getItem(localStorage.key(i))
+ "</li>";
}
document.getElementById("localStorageData").innerHTML = localhtml;
/* Get the session storage item */
for (var j = 0; j < sessionStorage.length; j++) {
sessionhtml += "<li>" + sessionStorage.key(j) + " : "
+ sessionStorage.getItem(sessionStorage.key(j))
+ "</li>";
}
document.getElementById("sessionStorageData").innerHTML = sessionhtml;
}
tizen.filesystem.resolve('/opt/apps/trial/data', function(
dir) {
documentsDir = dir;
dir.listFiles(onsuccess, onerror);
}, function(e) {
console.log("Error" + e.message);
}, "rw");
}
</script>
この部分では:
tizen.filesystem.resolve('/opt/apps/trial/data', function(
dir) {
documentsDir = dir;
dir.listFiles(onsuccess, onerror);
}, function(e) {
console.log("Error" + e.message);
}, "rw");
}
trial
はアプリ ID です。tizen フォンからアプリ ID を取得する方法がわかりません。データは正常に保存されますが、保存されたデータを取得できません。