MySQL Library for Android
With this library you can now connect directly your Android apps to any mysql database server
Setup
- Download the attached library and copy all three files to the libraries folder.
Example
MySQL_1.01.zip
With this library you can now connect directly your Android apps to any mysql database server
Setup
- Download the attached library and copy all three files to the libraries folder.
Example
B4X:
Sub Process_Globals
End Sub
Sub Globals
Dim mh1 As MysqlHandler
Dim rs1 As ResultSet
Dim sv1 As ScrollView
Dim lv1 As ListView
Dim hsv1 As HorizontalScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
mh1.Initialize("ip.mysql.server[:port]","db_name","db_user","db_password")
If mh1.isConnected = False Then
Msgbox(mh1.SQLError, "Connection Error:")
Return
End If
rs1 = mh1.Query("SELECT * FROM table_name")
If rs1.IsInitialized = False Then
Msgbox("ResultSet is empty" & CRLF & mh1.SQLError, "Warning")
Return
End If
hsv1.Initialize(rs1.ColumnCount * 150dip,0)
Activity.AddView(hsv1,0,0,100%x,100%y)
sv1.Initialize(rs1.RowCount * 30dip)
hsv1.Panel.AddView(sv1,0,0,rs1.ColumnCount*150dip,100%y)
Dim l As Label
For i=0 To rs1.RowCount - 1
rs1.Position = i
For j=0 To rs1.ColumnCount - 1
l.Initialize("label" & j)
l.Text = rs1.GetString(j)
l.TextColor = Colors.Black
l.Color = Colors.White
sv1.Panel.AddView(l,j*150dip,i*30dip,149dip,29dip)
Next
Next
mh1.Close
End Sub
Last edited: