Android Question Android Sqlite

DEiv

New Member
I need to connect my work with SQLite, but do not save anything and not give me error. Do not know how to fix it . I hope someone help me please! Thank you

Activity Registro
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
   
    'Declarar SQL
    Dim sen As SQL
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.

    Private res_sesion As Button
    Private registrate As Button
    Private reg_usuario As EditText
    Private reg_nombres As EditText
    Private reg_apellidos As EditText
    Private reg_correo As EditText
    Private reg_fecha As EditText
    Private reg_pass As EditText
   
    'Declarar Variables

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("Layout3")   
   
    If File.Exists(File.DirRootExternal,"dato.db") = False Then
        File.Copy(File.DirAssets,"dato.db",File.DirRootExternal,"dato.db")
    End If
   
    sen.Initialize(File.DirRootExternal,"dato.db",True)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub registrate_Click
   
    If reg_nombres.Text<>Null And reg_apellidos.Text<>Null And reg_usuario.Text<>Null And reg_pass.Text<>Null And reg_fecha.Text<>Null And reg_correo.Text<>Null Then
        sen.ExecNonQuery2("INSERT INTO PERSONA (per_codigo,per_nombres,per_apellidos,per_usuario,per_pass,per_fecha,per_correo) VALUES(NULL,?,?,?,?,?,?)", Array As String(reg_nombres.Text,reg_apellidos.Text,reg_usuario.Text,reg_pass.Text,reg_fecha.Text,reg_correo.Text))
        reg_apellidos.Text= ""
        reg_nombres.Text=""
        reg_correo.Text=""
        reg_usuario.Text=""
        reg_pass.Text=""
        reg_fecha.Text=""
    Else   
        Msgbox("Verifica que todos los campos esten llenos.","Advertencia")
    End If
End Sub

Sub res_sesion_Click
    Msgbox("Debe de tener una cuenta para Iniciar Sesión.","Advertencia")
    StartActivity("Main")
End Sub
 

Attachments

  • Registrar.bas
    2.1 KB · Views: 119

DEiv

New Member
As a start 'sen'
I am sorry
(I'm new using B4A)

I have a question... only loading the file dato.db(my database) in files of b4a... it runs the database??
 
Last edited:
Upvote 0

DEiv

New Member
Thank you... I don't speak english.. and i don't use translators because sometimes they do not translate well
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Change Activity_Create.
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout3")  
    If FirstTime = True Then
        If File.Exists(File.DirRootExternal,"dato.db") = False Then
            File.Copy(File.DirAssets,"dato.db",File.DirRootExternal,"dato.db")
        End If
        sen.Initialize(File.DirRootExternal,"dato.db",True)
    End If
End Sub
And change this line:
B4X:
 If reg_nombres.Text<>"" And reg_apellidos.Text<>"" And reg_usuario.Text<>"" And reg_pass.Text<>"" And reg_fecha.Text<>"" And reg_correo.Text<>"" Then

SQLite databases are explained in the User's Guide not in the Beginner's Guide.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…