Share My Creation iSQLiteLight Three simple SQLite projects

klaus

Expert
Licensed User
The three projects are portations of the three BA4 SQLiteLight programs to B4i.

These examples are explained in the B4XSQLiteDatabase Booklet.

- iSQLiteLight1
A very simple project with a very simple user interface with following functions:
At the first run the database is empty and the user must add entries.
- Add an entry
- Edit an entry
- Update an entry
- Delete an entry
- Display next and previous entry

- iSQLiteLight2
A simple project with some more functions:
A default database is supplied to allow the use of the filter without the need to add many entries.
- Display the database in a table with following functions:
-- Add display the Edit activity to add a new entry
-- Edit display the Edit activity to edit an entry
-- Filter filter the database
-- Set Filter display the Filter activity to set the filter
- Edit
-- Add / Update / Delete
-- First / Previous / Next / Last
- Filter

The database is very simple with four columns :
- ID
- FirstName
- LastName
- City

- iSQLiteLight3
Same as SQLiteLight2, all functions are the same.
The differences are the database path, database name, table name, columb number, column names, column alias names and column data types are variables instead beeing hard coded.
It allows also to generate a new database by:
- changing in Globals the values of the variables listed above
- in Activity_Create
-- comment this line : 'File.Copy(File.DirAssets, SQLDateBaseName, SQLDataBasePath, SQLDateBaseName)
-- uncomment this line : CreateDataBase

The code has comments and is, I hope, self explanatory.
 

Attachments

Last edited:

klaus

Expert
Licensed User
Hello @klaus, did it take long to port?
Well, I haven't measured the time.
It wasn't complicated, but much time was spend to learn B4i related to iOS.
Even the SQLite treatment is a bit different.
It will probably take about half the time for future projects when getting more experience.
You need to get accustomed to the different user interface specific to iOS and the different views.
This link is useful to get an 'iOS feeling'.
To move from B4A to B4i, begin with 'simple' projects to master the differences between the two systems.
 

klaus

Expert
Licensed User
You may have a look at the B4A SQLiteLight examples in my signature.
SQLiteLight1 is the simplest you can do, a B4i version will come.
Have a look at the SQLite chapter in the User's Guide.
 
Last edited:

ilan

Expert
Licensed User
hi klaus, i tried your example (iSQLlight1) and its really great. i started to learn sql now, there i can find anything i need for my app except of one thing.

there is a example how to add new entry, edit, delete only no search for an entry. like i have an entry where i dont know the ID but i know the name of the person in this entry how do i get it??

well i figured it out after few minutes and come up with this.


B4X:
Sub Button1_Click
    Dim whatcolum As String = "Firstname"
    Dim search As String = "ilan"
 
    sqlsearch(whatcolum,search)
End Sub

Sub sqlsearch(tosearch As String, txt As String)
 
    Dim Query As String
    Dim ResultSet1 As ResultSet
 
    Query = "SELECT * FROM persons WHERE " & tosearch & " = ?"
    ResultSet1 = SQL1.ExecQuery2(Query, Array As String (txt))

    If ResultSet1.NextRow = True Then
        lblID.Text = ResultSet1.GetString("ID")
        CurrentIndex = NumberFormat(lblID.Text - 1,1,0)
        txfFirstName.Text = ResultSet1.GetString("FirstName")
        txfLastName.Text = ResultSet1.GetString("LastName")
        txfCity.Text = ResultSet1.GetString("City")
    End If

    ResultSet1.Close                                                                     
End Sub
thank you very much for this example now i can start with my new app (i know how to add, edit, delete and search in sql database):)
 

Beja

Expert
Licensed User
Hi Klaus,
Are these projects available for B4J too. Thanks.
 

klaus

Expert
Licensed User
Sorry, no.
I have never really used B4J.
I think that it shouldn't be that difficult to adapt them because the main differences between the B4A and B4i versions are the operation system differences not SQLite differences.
 
Top