I have a problem, I am trying to connect to a MySQL database using AsyncTask
. I put the connection code in the button event but it gives me error,
Here
Your error is: TextView tv = (TextView)this.findViewById(R.id.textView1);
because it is declared outside of onCreate
.
So this is what you have to do, declare TextView tv;
above onCreate
. Then inside onCreate
you add tv = (TextView) findViewById(R.id.textView1);
And remove the duplicate of:
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);