Yes, You can.
Bạn phải thêm thư viện jar cho mysql. Sau đó mã java sẽ kết nối với máy chủ mysql.
import java.sql.DriverManager;
import android.database.SQLException;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.ResultSet;
import com.mysql.jdbc.Statement;
public class SQLConnection {
public static Connection conn = null;
static void setConnection(String user,String pass,String urlServer,String dBase){
try
{
String userName = user;
String password = pass;
String url = "jdbc:mysql://"+urlServer+"/"+dBase;
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println (e.getMessage());
}
finally
{
}
}
public static Connection getConnection(){
return conn;
}
}