Android SQLite debugging
Debugging SQLite artifacts, you no longer need to Log your own, just a few simple commands. Adb shell setprop log. tag. SQLiteLog Vadb shell setprop log. tag. SQLiteStatements Vadb shell stopadb shell start results are as follows V/SQLiteStatements (4405):/data/[package]/databases/[db_name]. db: "UPDATE [table_name] SET state =-1 WHERE note_id = '000000'" It's easy to close the Log, change "V" in the above Code to "", and then describe it in the source code SQLiteDebug. in java,/*** 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 t Aken 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); VERBOSE is used in the source code, and we can also use V. Check the implementation of isLoggable and the isLoggable method is native, the actual execution is the android_util_Log_isLoggable method of frameworks/base/core/jni/android_util_Log.cpp. android_util_Log_isLoggable calls the isLogg in the same file Able static jboolean isLoggable (const char * tag, jint level) {String8 key; key. append (LOG_NAMESPACE); key. append (tag); char buf [PROPERTY_VALUE_MAX]; if (property_get (key. string (), buf, "") <= 0) {buf [0] = '\ 0';} int logLevel = toLevel (buf ); return logLevel> = 0 & level> = logLevel;} In isLoggable, use propery_get to obtain the previously set value, then call toLevel static int toLevel (const char * value) {switch (value [0]) {Case 'V': return levels. verbose; case 'D': return levels. debug; case 'I': return levels.info; case 'W': return levels. warn; case 'E': return levels. error; case 'A': return levels. assert; case's ': return-1; // SUPPRESS} return levels.info;} toLevel only determines the first character of the value, so we can set only V before, as long as it starts with V, it doesn't matter if it is followed by any character.