Creating an sqlite db outside of B4A

Ricky D

Well-Known Member
Licensed User
Longtime User
What tools are available to create sqlite databases I can put in my app?

I've tried creating one from the firefox sqlite manager add on but B4A wouldn't read it.

Any ideas?

regards, Ricky
 

Ricky D

Well-Known Member
Licensed User
Longtime User
have you used it?

I am wondering if it works with b4a?

regards, Ricky
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
Key field though?

I can't set a field to be the key for the table

How do you do that?

regards, Ricky
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
I can't afford to buy more software so this will have to do

but how do I create the field manually and what format would it be?

regards, Ricky
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
I use SQLite Database Browser to create db on Windows and then bundle it with the Android apps. The database it creates is 100% compatible with B4A. You can create tables and add data manually or you can import from CSV files as well. It also has an option to test SQL queries and see the data that gets returned which is convenient as you can fine tune the queries and use it on B4A instead of doing trial and error on B4A itself.

And the best part - it is free

windowsxp.jpg
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
ok...

Back to my original problem.

It doesn't have boolean.

How do you handle booleans in android sqlite?

:BangHead:

regards, Ricky
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Inman, the version you posted is the "old" version of SQLiteStudio.

Really? Never knew it. I downloaded it 2 years back for another project and never had to look for another app (or even an update) as it fit all my needs.
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
Even setting the type to boolean didn't work

I created a simple table :

Shifts
TableID Int Primary Key Not Null
IsLocked boolean

then when I run this sql in the Execute Sql pane on sql studio

Insert Into Shifts (TableID,IsLocked) Values (1,true)

it threw an error

changing it to

Insert Into Shifts (TableID,IsLocked) Values (1,1)

worked

So I'll store them as Int with false=0 and true=1

cheers, Ricky
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
I created a simple table :

Shifts
TableID Int Primary Key Not Null
IsLocked boolean

then when I run this sql in the Execute Sql pane on sql studio

Insert Into Shifts (TableID,IsLocked) Values (1,true)

it threw an error

changing it to

Insert Into Shifts (TableID,IsLocked) Values (1,1)

worked

So I'll store them as Int with false=0 and true=1

cheers, Ricky

That behaviour sounds like the way MySQL handles Boolean data type.

MySQL does in theory have a Boolean data type but:

These types are synonyms for TINYINT(1). A value of zero is considered false. Nonzero values are considered true

That's a quote from MySQL :: MySQL 5.0 Reference Manual :: 10.1.1 Numeric Type Overview.

Use an Integer data type in SQLite and you'll have no problems.

Martin.
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
that's it

:icon_clap:

Thanks for showing me that. I've implemented it as ints and is working just fine.

cheers, Ricky
 
Upvote 0

mjtaryan

Active Member
Licensed User
Longtime User
Back to my original problem.

It doesn't have boolean.

How do you handle booleans in android sqlite?

:BangHead:

regards, Ricky

I don't know whether you got an answer to your question, but I was just reading some SQLite documentation and came across just the info you need.


SQLite, first of all, does not employ datatypes in the more common fashion. And second, with reference to your question, implements Boolean as an integer with 0 = False and 1 = True. For more details go to SQLite.org and search for "Boolean". Hope this helps.
 
Upvote 0
Top