As I have already said in other posts, StackOverflow is a good place where find interesting ideas for writing a post. Some days ago I found the following post:

Android Room Database DAO debug log

The question was: is there a way to log SQL queries with Room library? The answer was no.

And with Kripton? The answer is YES! Since version 1 SQL log was in the features of the ORM module. You have to do nothing. Just use Kripton. In the generated code, Kripton pulls all the necessary code to write log (that you can easily read into logcat).

You can simply check the basic sample on kripton-examples.

When you run the sample code, you will see in your log, something like this:

Kripton generates for us at compile all the code necessary to log SQL operations. The pieces of information printed are:

  • The SQL code
  • The parameter with its value and type
  • For the select operation, the number of the rows extracted.

If you want to disable this feature, you can simply set to false an attribute named logs on @BindDataSource to disable SQL logs generation.

As usual, for more information about Kripton Persistence Library, please visit:

Happy coding!

Francesco

 

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close