@@ -25,6 +25,25 @@ allprojects {
2525## Methods and how to use them
2626We have Two classes FetchData and PutData. Import the Library to your file first (In android studio paste the code and press alt + enter).
2727### Read Data From a URL - FetchData.class
28+ You need to use Handler and post a Runnable. Inside the run method add the code for FetchData.
29+
30+ * Creating the object for FetchData, pass the URL as argument.
31+ ```
32+ FetchData fetchData = new FetchData("https://projects.vishnusivadas.com/AdvancedHttpURLConnection/readTest.php");
33+ ```
34+ * Calling startFetch() returns a boolean value.
35+ ```
36+ fetchData.startFetch();
37+ ```
38+ * To know when the process is completes use onComplete() which returns a boolean value.
39+ ```
40+ fetchData.onComplete();
41+ ```
42+ * If the process is complete, use the getResult() to get the result value.
43+ ```
44+ fetchData.getResult();
45+ ```
46+ * Full implimentation with Handler. You can also add a progress bar at the commended regions.
2847```
2948//Start ProgressBar first (Set visibility VISIBLE)
3049Handler handler = new Handler();
@@ -44,6 +63,40 @@ handler.post(new Runnable() {
4463```
4564
4665### Write data with POST and GET methods - PutData.class
66+ You need to use Handler and post a Runnable. Inside the run method add the code for PutData.
67+
68+ * First we need to create to arrays, one for field name of the parameter and another for the data. Make sure the order is correct.
69+ ```
70+ String[] param = new String[2];
71+ param[0] = "param-1";
72+ param[1] = "param-2";
73+ String[] data = new String[2];
74+ data[0] = "data-1";
75+ data[1] = "data-2";
76+ ```
77+ * PHP representation, The post array will look like,
78+ ```
79+ $_POST['param-1'] = "data-1";
80+ $_POST['param-2'] = "data-2";
81+ ```
82+
83+ * Creating the object for PutData, pass the URL, method, field, data as arguments. The method can be POST and also GET.
84+ ```
85+ PutData putData = new PutData("https://projects.vishnusivadas.com/AdvancedHttpURLConnection/putDataTest.php", "POST", param, data);
86+ ```
87+ * Calling startFetch() for starting the process, it returns a boolean value.
88+ ```
89+ putData.startFetch();
90+ ```
91+ * To know when the process is completes use onComplete() which returns a boolean value.
92+ ```
93+ putData.onComplete();
94+ ```
95+ * If the process is complete, use the getResult() to get the result value.
96+ ```
97+ putData.getResult();
98+ ```
99+ * Full implimentation with Handler. You can also add a progress bar at the commended regions.
47100```
48101//Start ProgressBar first (Set visibility VISIBLE)
49102Handler handler = new Handler();
@@ -59,7 +112,7 @@ handler.post(new Runnable() {
59112 String[] data = new String[2];
60113 data[0] = "data-1";
61114 data[1] = "data-2";
62- PutData putData = new PutData("https://projects.vishnusivadas.com/AdvancedHttpURLConnection/putDataTest.php", "GET ", param, data);
115+ PutData putData = new PutData("https://projects.vishnusivadas.com/AdvancedHttpURLConnection/putDataTest.php", "POST ", param, data);
63116 if (putData.startFetch()) {
64117 if (putData.onComplete()) {
65118 String result = putData.getResult();
0 commit comments