Debug WebView Database Exception (reprint)

Source: Internet
Author: User

Android has a non-mandatory exception that is often found on the online crash: sqliteexception
This abnormal many people in the use of WebView, it is not necessary, the probability is not high, you will usually be online crash report will find it. There are divergent reasons. Here are two triggering scenarios:
1, SQLite in order to protect the db file consistency, when accessing the DB file, will give the file a process lock, in this case, if there is another process to access the DB file, there will be an error. So, you must have thought that your apk will trigger this exception if the following two conditions are met: 1, using WebView 2, using multiple processes. Because WebView will write the cache to the db file, it will certainly involve the DB operation, which is application range. When multiple processes are used, there is a possibility that the webview of different processes will operate on the same DB file process, and the exception is occasionally thrown out.
Finally, in accordance with the old Android code of the style of farming, of course, to give a solution: rewrite the application.openorcreatedatabase, so that different processes to create a different db file is good.
2, Cookiesyncmanager in the forced synchronization of cookies will also appear in SQLite IO exception. Therefore, forced synchronization requires careful use. If you do not involve multi-process sharing cookies, it is best not to force synchronization yourself.

Debug WebView Database Exception (reprint)

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.