Android Question Help:- Sqlite Printf() and TableView

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

https://www.b4x.com/android/forum/threads/sqlite-question.52424/#post-328274

The above thread is more than a year old, so I started a new thread regarding this.

From the above thread I understand that the Printf() was added as a core function in version 3.8.3 of sqlite3.
So any sql queries using Printf() will create a run time error on devices that are pre Lollypop.

For Eg.
B4X:
SELECT printf("%.2f",Price) As Price  // Returns 20.00

My app will be used on Pre-Lollypop devices too for eg Android 4.4.2
In better words, my app should work on all devices irrespective of the Sqlite versions bundled along with the Android OS.

Anybody here knows a similar function that works on all versions. Or what is the better way to move ahead.

I know that there are functions available on B4A to format numbers.

I use TableView and to load data to TableView I use
B4X:
TblView.LoadSQLiteDB(Starter.SQL1, cSql, True)

I expect formatted output from the SQL itself to load data to TableView.

Or is there any way by which I can set the format of the Column of a TableView so that I can do SQL query without using Printf() and set the Column formatting of the TableView to the way I want to present the data to the user.

Another question is:- Is there anyway that I can upgrade the Sqlite version to the latest on devices that are running Pre-Lollypop ?

Any advice will be appreciated
 

Mahares

Expert
Licensed User
Longtime User
Another suggestion:
1.Extract data from the table:
2. Add it to a list as you like to format it using numberformat2
Log(NumberFormat2(cursor1.getdouble("col7"),0,2,2,False))
3. Display data in tableview from the list
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Try the attached test program.
I added LoadSQLiteDB3 where you can define a simplified column fromatting.
Attached a small test program with the Table class version 2.18.
 

Attachments

  • TestTableColumnFormat.zip
    22.5 KB · Views: 182
Upvote 0
Top