The difference between Getreadabledatabase and getwritabledatabase

Source: Internet
Author: User

In Android, you can get an instance of the database that can be manipulated by Getreadabledatabase and Getwritabledatabase (). Then can be added to the database, delete, check, change. , but there is a difference between the two

1.getReadableDatabase is the first to read and write to open the database, but when the database disk is full, it will open failure, after failure, the program will try to open the database as read-only, if you can complete the required tasks, the read-only database will be closed. Returns a read-write database object.

2.getWritableDatabase is also read-write to open the database, but when the database disk is full, it will open the failure, and then because the use of getwritabledatabase, so open a read-only database has failed, then the program will be wrong

The Getwritabledatabase method is called in the 3.getReadableDatabase method

The source code is:

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/85/DC/wKiom1esdAuh1tMMAAEDxkzJogY504.png-wh_500x0-wm_3 -wmp_4-s_4280600721.png "style=" Float:none; "title=" Sql9.png "alt=" Wkiom1esdauh1tmmaaedxkzjogy504.png-wh_50 "/>

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/85/DB/wKioL1esdA3Sq_PNAAESOG8jztI277.png-wh_500x0-wm_3 -wmp_4-s_110437772.png "style=" Float:none; "title=" Sql10.png "alt=" Wkiol1esda3sq_pnaaesog8jzti277.png-wh_50 "/>

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/85/DB/wKioL1esdA7A5UsJAADNuBb8lyw801.png-wh_500x0-wm_3 -wmp_4-s_713253605.png "style=" Float:none; "title=" Sql11.png "alt=" Wkiol1esda7a5usjaadnubb8lyw801.png-wh_50 "/>


This article is from the "11828641" blog, please be sure to keep this source http://11838641.blog.51cto.com/11828641/1837074

The difference between Getreadabledatabase and getwritabledatabase

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.