In my app I will create a JSON file that contains this kind of information:
{
"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"
}
]
}
}
(this is the JSON I create for the iPhone app). Now I need to create a JSON file for the Android app.
First question: how I can create a JSON in Android, on here I found this: create json in android, but this will create a JSON without array (you can see in my JSON I've an array of site)?
Second question: you can see that in my JSON there are the path of the html file I downloaded in the Documents folder of iPhone, now in Android I stored the html with this code:
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();
}
How I can know the path where this file are stored?
Thank you