I know it's a strange question but I need one thing: I receive a string as a result of a http operation. In reality this string contains an array of strings like this:
["Leon","Prova 2","TestData"]
Basically I want to convert this string into an ArrayList because I need it for an adapter. This is the java code:
public class Archivio{
static ArrayList<String> titoli = new ArrayList<String>();
static ArrayList<String> art = new ArrayList<String>();
static String response, response2 = null;
HttpClient httpclient;
HttpPost httppost,httppost2;
List<NameValuePair> nameValuePairs,namePairs;
@SuppressLint({ "NewApi", "NewApi", "NewApi" })
Archivio() {
try {
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
httpclient=new DefaultHttpClient();
httppost= new HttpPost("http://tripleleon.altervista.org/artiview2.php");
nameValuePairs = new ArrayList<NameValuePair>();
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
//Esecuzione richiesta HTTP Post e ricezione risultato operazione
//response=httpclient.execute(httppost);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
response = httpclient.execute(httppost, responseHandler);
System.out.println("Response : " + response);
httppost2= new HttpPost("http://tripleleon.altervista.org/artiview3.php");
namePairs = new ArrayList<NameValuePair>();
httppost2.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler<String> responseHandler2 = new BasicResponseHandler();
response2 = httpclient.execute(httppost2, responseHandler2);
System.out.println("Response : " + response2);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
ArrayList<String> retTitle() {
return response;
}
ArrayList<String> retArt() {
return response2;
}
}