popolate six spinner and save with database

fifiddu70

Well-Known Member
Licensed User
Longtime User
Hello everyone, I'm trying to figure out how to change an example NjDude had sent me on the forum, it is a popular SQL database where a dispute through a editext spinner and a button, now I want popular 6 spinner through a editext, as I do?
I enclose an example of NjDude where you can only populate a spinner.

B4X:
'Activity module

Sub Process_Globals
  
          'These global variables will be declared once when the application starts.
      'These variables can be accessed from all modules.

    Dim dbSQL As SQL
            Dim dbCursor As Cursor
            
End Sub

Sub Globals
   
      'These global variables will be redeclared each time the activity is created.
      'These variables can only be accessed from this module.

      Dim Spinner1 As Spinner
      Dim EditText1 As EditText      
            Dim Button1 As Button
            
End Sub

Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("Main")
            
            If File.Exists(File.DirDefaultExternal, "Test.db") = False Then
            
         File.Copy(File.DirAssets, "Test.db", File.DirDefaultExternal, "Test.db")
                     
      End If
            
            dbSQL.Initialize(File.DirDefaultExternal, "Test.db", True)   
            
            PopulateSpinner

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause(UserClosed As Boolean)

End Sub

'##########################
'######## Controls ########
'##########################

Sub Button1_Click

    dbSQL.ExecNonQuery2("INSERT INTO Field1 VALUES (?)", Array As String(EditText1.Text))
            
            Spinner1.Add(EditText1.Text)
            
            EditText1.Text = ""
            
            dbCursor.Close
   
End Sub

'##########################
'######## Routines ########
'##########################

Sub PopulateSpinner

            dbCursor = dbSQL.ExecQuery("SELECT * FROM Field1")

            For I = 0 To dbCursor.RowCount - 1
            
                DoEvents
                        
                        dbCursor.Position = I
                        
                        Spinner1.Add(dbCursor.GetString("Data"))
            
            Next   
            
            dbCursor.Close

End Sub

i hope in your help
 

fifiddu70

Well-Known Member
Licensed User
Longtime User
I solved, I downloaded sqlite browser, I created a database with 6 tables, I managed to integrate my application with basic4android, I added the spinner and it works great.
I'm finally starting to understand how it works SqlLite.:sign0060:
 
Upvote 0
Top