About Android Studio view SQLite database

Connect to SQLite database

For the as internal simulator, you can use App Inspection, which supports API26 and above

Advantages: This is the most convenient way to view changes in the data table in real time

Disadvantages: only supports internal simulator, there are many things to install, very slow, poor machine performance and very stuck

For third-party simulators, you can find the .db file of the app through Device File Explorer to view it

The .db generation location and name need to be configured to determine

litepal.xml

<?xml version="1.0" encoding="utf-8"?>
<litepal>    
<!--
    定义应用程序的数据库名称。默认情况下,每个数据库名称应以.db结束。如果你没有名字数据库以.db结束, LitePal将为您自动加上后缀。例如:    
    <dbname value="demo" />
    -->    
<dbname value="demo" />    
<!--
        定义数据库的版本。每一次当你想要数据库升级时,版本标记会有帮助。
        修改模型中定义的映射标签“version”,就使版本值+ 1,数据库的升级将自动处理而不会出现问题。例如:   
    <version value="1" />
    -->    
<version value="1" />    
<!--
    在映射标签列表中定义您的模型,LitePal将会为每个映射类创建表。支持类中字段被映射到列。例如:   
    <list>
    <mapping class="com.test.model.Reader" />
    <mapping class="com.test.model.Magazine" />
    </list>
    -->    
<list>   
 </list>        
<!--
        定义.db文件的位置。
        “internal”表示.db文件将存储在内部存储的数据库文件夹中,无人可以访问。
        “external”表示.db文件将存储在主外部存储设备上目录的路径中,每个人都可以访问的永久文件。
        默认值为“内部 internal”。 例如:
        <storage value =“external”/>
    -->    
</litepal>

The location of the .db file in the simulator

You need to install a plug-in or other software to view the data, and you cannot query it in real time

The specific method is to find the .db file and double-click to generate a copied file on the computer's disk (or copy the file directly from the simulator folder), and then view it through Database Navigator or SimpleSqliteBrower

The generated files can be queried through tools such as everyThing

Database Navigator: The menu name is DB Browser

 

Select the directory where the .db file is generated

SimpleSqliteBrower:

Just double click to view

 

Guess you like

Origin blog.csdn.net/fffd345/article/details/126836369