Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print sqlite query to logCat

Is there a way to print my sqlite query to logCat? Here is my query

db.query(TABLE, projection, selection, selectionArgs, null, null, null)
like image 919
Nouvel Travay Avatar asked Dec 07 '22 23:12

Nouvel Travay


1 Answers

You can Try to add

adb shell setprop log.tag.SQLiteLog V
adb shell setprop log.tag.SQLiteStatements V

For ormlite

adb shell setprop log.tag.StatementExecutor VERBOSE 
adb shell setprop log.tag.BaseMappedStatement VERBOSE 
adb shell setprop log.tag.MappedCreate VERBOSE 
adb shell setprop log.tag.ORMLite DEBUG

You may need to restart Android Studio.

Edit 1: I test sqllite on Mobile, the configs seem useless.I don't know the reason. It doesn't work as the source code say:

public final class SQLiteDebug {
    private static native void nativeGetPagerStats(PagerStats stats);

    /**
     * Controls the printing of informational SQL log messages.
     *
     * Enable using "adb shell setprop log.tag.SQLiteLog VERBOSE".
     */
    public static final boolean DEBUG_SQL_LOG =
            Log.isLoggable("SQLiteLog", Log.VERBOSE);

    /**
     * Controls the printing of SQL statements as they are executed.
     *
     * Enable using "adb shell setprop log.tag.SQLiteStatements VERBOSE".
     */
    public static final boolean DEBUG_SQL_STATEMENTS =
            Log.isLoggable("SQLiteStatements", Log.VERBOSE);

    /**
     * Controls the printing of wall-clock time taken to execute SQL statements
     * as they are executed.
     *
     * Enable using "adb shell setprop log.tag.SQLiteTime VERBOSE".
     */
    public static final boolean DEBUG_SQL_TIME =
            Log.isLoggable("SQLiteTime", Log.VERBOSE);

    /**
     * True to enable database performance testing instrumentation.
     * @hide
     */
    public static final boolean DEBUG_LOG_SLOW_QUERIES = Build.IS_DEBUGGABLE;

    private SQLiteDebug() {
    }
 }

enter image description here enter image description here

like image 56
tiny sunlight Avatar answered Dec 11 '22 11:12

tiny sunlight