Private static final String pass = "1234" Īnd initialize them onCreate method : txtData = (TextView) this.findViewById(R.id.txtData) ītnFetch = (Button) findViewById(R.id.btnFetch) ītnClear = (Button) findViewById(R.id.btnClear) Private static final String user = "hitesh"
The layout contains a Android TextView to show our Table data from MySQL Database and two buttons, one for connecting to Database and other for clearing the TextView content.ĭeclare this variables in your Java class private static final String url = "jdbc:mysql://192.168.0.192:3306/myDB" Now, open your activity_main.xml file and edit it as below : Select distinct Country from tblCountries Insert into tblCountries (Country) values ('Spain') Insert into tblCountries (Country) values ('New Zealand') Insert into tblCountries (Country) values ('England') Insert into tblCountries (Country) values ('USA') Insert into tblCountries (Country) values ('Mauritius') Insert into tblCountries (Country) values ('Australia')
Insert into tblCountries (Country) values ('India')
ID int NOT NULL AUTO_INCREMENT primary key, MySQL Database Script : create schema myDB It will connect via IP address of the Database with a correct Database Credentials. You can always name your Package and Application name according to your requirements.Īpplication will first try to connect with the MySQL Database and on successful Database connection, android application will display data from a table on a Android TextView.