Android Question Sql always returning same result.

karld

Active Member
Licensed User
Longtime User
This is weird.
I am updating an app I wrote several years ago.
I decided to add a database table to track version info. Trying to implement database updates.

I created a sql read routine to read the version number. The first time I ran it returned the correct version number....
Now every time it returns that same number. I changed the entry in the db. I even deleted the db from the project and it still returns that number.
I stopped and restarted the emulator with the same results.

Now, I have not loaded it to a live device yet....

Could this be something in the emulator not updating the database on the virtual device?
Drove me nuts till almost 2am.....
When I get home from work I am going to take another stab at it....
 

Widget

Well-Known Member
Licensed User
Longtime User
There are 3 possibilities.

1) You are reading the version from a different database or table than you are updating.
2) You are using a transaction to update the table but you are forgetting to commit the transaction.
3) Is it possible your database is readonly. The DirAssets directory is readonly so make sure you are not trying to update a database in that directory.

BTW, you don't need to create a Version table.
SQLite can use:
PRAGMA user_version --To Get Database Version
PRAGMA user_version=1 --To Set Database Version

And of course when you update the version, either using your Version table or PRAGMA, read the version to make sure it is correct.

Hope this helps.
 
Upvote 0

karld

Active Member
Licensed User
Longtime User
Well.. I am manually updating the database and then closing it and re-opening it to verify the changes saved...
All my android code does is read it. I have not written anything to write to it yet.
I am pretty sure I am not writing and reading from different databases, but I have done dumber things.... LOL..
I will look into that.

Will investigate the PRAGMA command.... Never used that before.
 
Upvote 0

karld

Active Member
Licensed User
Longtime User
Upvote 0

karld

Active Member
Licensed User
Longtime User
OK.. Tonight I got things moving in the right direction...

I am using PRAGMA user_version to track the database to see if update is needed.
I got the SAX xml parser working.... I can read an update file now.
Got the xml data being written to the database to update it.

All that seems to be working.
I still need to add some error checking....

Next on the list is to figure out how to pull the xml file from an internet site to download.

All this is to be able to update the database for my app without having to release a new version every time....


Eriel.. I really love B4A!!!!!!

Thanks a ton for making this wonderful tool...
 
Upvote 0
Top