Send the contents of Android ArrayList to PHP

前端 未结 2 831
夕颜
夕颜 2021-01-24 02:34

I am working as a PHP developer (intermediate level) and do practice some android stuff at home.

I have created and array list which will fetch into an sqlite db inside

2条回答
  •  面向向阳花
    2021-01-24 02:42

    For that you have to post your data on php server, then fetch that data and store into your database .

    Here i attach one example which send data on server and getting response in json .

                        HttpPost postMethod = new HttpPost("Your Url");
                        List nameValuePairs = new ArrayList();
    
    
                        // test is a one array list
    
                        for(int i=0;i

    Here sample[] is a field in which i assign array value to send on server . From server side you have to fetch the sample[] field .


    public static String convertStreamToString(InputStream is)
    {
       BufferedReader reader = new BufferedReader(new InputStreamReader(is));
       StringBuilder sb = new StringBuilder();
    
       String line = null;
       try 
       {
           while ((line = reader.readLine()) != null) 
           {
               sb.append(line + "\n");
           }
       } 
       catch (IOException e) 
       {
           e.printStackTrace();
       } 
       finally 
       {
           try 
           {
               is.close();
           } 
           catch (IOException e) 
           {
               e.printStackTrace();
           }
       }
       return sb.toString();
    

    }

提交回复
热议问题