Not receiving data from MySQL database to Android Recyclerview
<p>I'm working on an amusement park record application that receives data from MySQL database and displays on recyclerview in android but im unable to download it from database. </p>

<p>This is my Adapter</p>

<pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyHolder&gt; {
Context c;
ArrayList&lt;String&gt; swing;

public MyAdapter(Context c,ArrayList&lt;String&gt;swing){
    this.c=c;
    this.swing=swing;
}

@Override
public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v= LayoutInflater.from(parent.getContext()).inflate(R.layout.card_ticketsold,parent,false);
    MyHolder holder=new MyHolder(v);

    return holder;
}

@Override
public void onBindViewHolder(MyHolder holder, int position) {
    holder.nameTxt.setText(swing.get(position));
    holder.setItemClickListener(new ItemClickListener() {
        @Override
        public void onItemClick(int pos) {
            Toast.makeText(c,swing.get(pos),Toast.LENGTH_SHORT).show();
        }
    });

}

@Override
public int getItemCount() {
    return swing.size();
}
</code></pre>

<p>}</p>

<p>this is my holder:</p>

<pre><code>public class MyHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView nameTxt;
ItemClickListener itemClickListener;

public MyHolder(View itemView) {
    super(itemView);

    nameTxt= (TextView) itemView.findViewById(R.id.swing_name_ticket_sold_text);

    itemView.setOnClickListener(this);
}


public void setItemClickListener(ItemClickListener ic)
{
    this.itemClickListener=ic;
}

@Override
public void onClick(View v) {
    this.itemClickListener.onItemClick(getLayoutPosition());
}
</code></pre>

<p>}</p>

<p>This is the fragment containing the recyclerview:</p>

<pre><code>public class TicketSoldFragment extends Fragment {
Button press;

String url="http:// 10.0.2.2/data/ticketsold_show_swing.php";

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView=inflater.inflate(R.layout.fragment_ticketsold,container,false);
    return rootView;

}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {

    final RecyclerView rv=(RecyclerView)view.findViewById(R.id.recyclerview_ticketsold);
    rv.setLayoutManager(new LinearLayoutManager(getContext()));
    rv.setItemAnimator(new DefaultItemAnimator());
    Context c=getActivity().getApplicationContext();

    press=(Button)view.findViewById(R.id.buttonplease);

    press.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Downloader d=new Downloader(getActivity(),url,rv);
            d.execute();
        }
    });

}
</code></pre>

<p>}</p>

<p>this is downloader:</p>

<pre><code>public class Downloader extends AsyncTask&lt;Void,Integer,String&gt; {

Context c;
String stringURL;
RecyclerView rv;
ProgressDialog pd;

public Downloader(Context c, String stringURL, RecyclerView rv) {
    this.c= c;
    this.stringURL = stringURL;
    this.rv = rv;


}

@Override
protected String doInBackground(Void... params) {

    String data=this.downloadData();

    return data;
}

@Override
protected void onPostExecute(String data) {
    super.onPostExecute(data);

    pd.dismiss();
    if(data!=null)
    {
        Parser p=new Parser(c,data,rv);
        p.execute();
    }
    else {
        Toast.makeText(c,"Unable to download",Toast.LENGTH_SHORT).show();
    }
}

private String downloadData()
{
    InputStream is=null;
    String line=null;
    try
    {
        URL url=new URL(stringURL);
        HttpURLConnection con= (HttpURLConnection) url.openConnection();
        is=new BufferedInputStream(con.getInputStream());

        BufferedReader br=new BufferedReader(new InputStreamReader(is));
        StringBuffer sb=new StringBuffer();

        if(br!=null)
        {
            while((line=br.readLine())!=null){
                sb.append(line+"\n");

            }
        }
        else {
            return null;
        }
        return sb.toString();

    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    finally {
        if(is!=null)
        {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    return null;
}


@Override
protected void onPreExecute() {
    super.onPreExecute();
    pd=new ProgressDialog(c);
    pd.setTitle("Download Data");
    pd.setMessage("Downloading...Please Wait!");
    pd.show();
}
</code></pre>

<p>}</p>

<p>and Parser:</p>

<pre><code>public class Parser extends AsyncTask&lt;Void,Integer,Integer&gt; {

Context c;
String data;
RecyclerView rv;

ProgressDialog pd;
ArrayList&lt;String&gt; swings=new ArrayList&lt;&gt;();
MyAdapter adapter;

public Parser(Context c, String data, RecyclerView rv) {
    this.c = c;
    this.data = data;
    this.rv = rv;
}

@Override
protected void onPreExecute() {
    super.onPreExecute();

    pd=new ProgressDialog(c);
    pd.setTitle("Parse Data");
    pd.setMessage("Parsing...Please wait!");
    pd.show();
}

@Override
protected Integer doInBackground(Void... params) {


    return this.parse();
}

@Override
protected void onPostExecute(Integer integer) {
    super.onPostExecute(integer);

    pd.dismiss();

    if(integer==1)
    {
        adapter=new MyAdapter(c,swings);
        rv.setAdapter(adapter   );
    }
    else
    {
        Toast.makeText(c,"Unable to parse data",Toast.LENGTH_SHORT).show();
    }
}

private int parse()
{
    try{
        JSONArray ja=new JSONArray(data);
        JSONObject jo=null;
        swings.clear();

        for(int i=0;i&lt;ja.length();i++)
        {
            jo=ja.getJSONObject(i);
            String name=jo.getString("name");
            swings.add(name);
        }
        return 1;

    } catch (JSONException e) {
        e.printStackTrace();
    }
    return 0;
}
</code></pre>

<p>}</p>

<p>when i run this, the Toast "Unable to download" appears...so my data is not downloaded at all! and there is an error in logcat "no network" and sendUserActionEvent() mView == null</p>