【发布时间】:2013-08-02 10:26:32
【问题描述】:
在我的应用程序中,我将创建一个包含此类信息的 JSON 文件:
{
"sites":{
"site":[
{
"src":"/Users/redoddity/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/EE5BB071-A217-4C8D-99BA-5B6F392889A6/Documents/Sito3.html",
"name":"Sito3",
"expiryDate":"29 Ago 2013"
},
{
"src":"/Users/redoddity/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/EE5BB071-A217-4C8D-99BA-5B6F392889A6/Documents/Sito2.html",
"name":"Sito2",
"expiryDate":"29 Ago 2013"
}
]
}
}
(这是我为 iPhone 应用程序创建的 JSON)。现在我需要为 Android 应用程序创建一个 JSON 文件。
第一个问题:如何在 Android 中创建 JSON,在这里我发现了这个:create json in android,但这将创建一个没有数组的 JSON(你可以在我的 JSON 中看到我有一个站点数组)?
第二个问题:你可以看到在我的JSON中有我在iPhone的Documents文件夹中下载的html文件的路径,现在在Android中我用这段代码存储了html:
File file = getFileStreamPath(titleText + ".html");
if (!file.exists()) {
try {
OutputStreamWriter out = new OutputStreamWriter(openFileOutput(titleText + ".html", 0));
out.write(html);
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
Log.d("FILE", "Il file esiste");
alert.show();
}
我如何知道这个文件的存储路径?
谢谢
【问题讨论】: