Android SQLite debugging

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.