Android & Database.readTransaction

I have learned that a SqlLite Database.readTransaction is just not working on Android. If you rely heavily on databases like my app does, it's a big problem. So, you have to use Database.transaction.

I did not however want to lose the slight boost of readTransaction for those that support it, so I found a way around the problem:

FlashCards.Database = window.openDatabase("FlashCards", "1.0", "FlashCards Database",500000);

if (FlashCards.fetchAppInfo.os == "android"){
FlashCards.Database.safeTransaction = FlashCards.Database.transaction;
}else{
FlashCards.Database.safeTransaction = FlashCards.Database.readTransaction;
}
FlashCards.fetchAppInfo.os is my personal way of configuring the OS deployment. I had to store the transaction object inside the Database namespace in order for it to work (FlashCards.safeTransaction throws Illegal invocation error).

Then I just did a global find/replace on FlashCards.Database.readTransaction to change it to FlashCards.Database.safeTransaction.

Credit goes to Philip Davis for realizing it needs to be in the Database namespace.

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter