
Android SQLite savepoints: nested transactions and workaround
Hello! In this article I’ll show one small trick with SQLite savepoints and my story how I’ve found this trick. Google claims that Android fully supports SQLite database engine. But the code that framework provides to us sometimes isn’t implemented well, so we cannot use some SQLite features and forced to search for workarounds. One of the features that doesn’t work as expected is savepoint. In short, it’s a tag in SQLite’s operations journal that can mark some important point in operations history to fall back to it if something was wrong. It’s similar to transaction, but savepoints have one big advantage over transactions: you can have as much savepoints as you need. You can have only one transaction at the time, but when you need to undo only particular changes inside huge transaction, savepoint can be used. Actually, savepoints are transactions, but with names and with possibility to nest multiple transactions inside one. ...