View SQLite database on device in Android Studio

前端 未结 4 1533
情歌与酒
情歌与酒 2020-12-14 02:10

I am using the latest version of Android Studio. When I run my app on the emulator, I am able to view my database by going through:

tools -> Android Device

4条回答
  •  再見小時候
    2020-12-14 03:09

    The easiest way to see realtime Database are:

    #For Android Studio 4.1 Canary 6 and higher

    You can use a very simple Android Studio's feature Database Inspector. Where you can inspect, query, and modify your app’s databases using the new Database Inspector. For example, you can debug your running app by modifying values in your database and testing those changes on the device in real-time without leaving Android Studio.

    To get started, deploy your app to a device running API level 26 or higher and select View > Tool Windows > Database Inspector from the menu bar.

    #For Android Studio 4.0 and lesser

    Use the Android Debug Database library

    • Android Debug Database allows you to edit, delete, create the database and shared preferences values directly in your browser in a very simple way
    • Search in your data
    • Debug Room in-memory database
    • No need to root device

    Using:


    Add this to your app's build.gradle

    debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
    

    Launch/Run app


    Find the debugging link in logs in LogCat

    i.e. D/DebugDB: Open http://192.168.232.2:8080 in your browser
    

    the link will be different and open it in the any browser

    That's it Enjoy!!!

    • If you are using it over USB, run ADB forward tcp:8080 tcp:8080
    • Android phone and laptop should be connected to the same Network

    For more details go to the library.

提交回复
热议问题