实际上我正在列表视图中访问歌曲详细信息,现在我想将它们存储在我的服务器上(整个列表项)。我是Android的新手。请帮我。
我已经制作了需要json的php web服务
必填项:
$inputJSON = '{
"currentTimeStamp" : 1446786632.036515,
"songData" : [
{
"SongID" : "2",
"status" : "1",
"albumTitle" : "Zid",
"playbackDuration" : 289.802,
"artist" : "Sharib-Toshi, Sunidhi Chauhan, Sharib Sabri",
"podcastTitle" : "Zid",
"assetURL" : "ipod-library:\/\/item\/item.mp3?id=4206809166388889270",
"isSelected" : "1",
"albumArtist" : "Sharib-Toshi",
"title" : "Tu Zaroori (Duet) - WapLoft.`enter code here`Com"
}
],
"UserID" : "2"
}';
答案 0 :(得分:0)
如果您正在使用光标,则必须运行光标并创建歌曲数据的JSON数组。
首先创建一个JSONArray,如下所示
awk -F"," 'NR==FNR { n[$2] = $1; next } ($1 in n) {print $1,$2,$3,n[$1],n[$2],n[$3] }' file1 file2
"c8:14:79:b4:bc:da",2016-03-0804:26:06,"TRUE","971509525934",, "58:48:22:83:87:7f",2015-12-22 01:22:42,"TRUE","971506904830",,
现在将所有歌曲放在数组中,就像在任何数组中一样
JSONArray songArray= new JSONArray();
其中
songsArray.put(eachSongsJsonObject);
等等,直到获得所有数据。完成所有操作并完成Json数组后,创建要发送的主JSONobject,如下所示
eachSongsJsonObject = new JSONObject();
eachSongsJsonObject.put("SongID",<the song id you got from cursor>);
eachSongsJsonObject,put("albumTitle",<album title>);
然后您可以将jsonObject发送到您的服务器并将其保存在那里。要将JSON发送到您的服务器,请使用volley库进行JsonObjectRequest调用。您可以通过以下链接实现截击。