如何在Android Studio上获取Sqlite数据库中插入数据的实时视图 [英] How to get the live view of inserted data in Sqlite database on Android Studio

查看:697
本文介绍了如何在Android Studio上获取Sqlite数据库中插入数据的实时视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请您帮我解决这个问题.

Will you please help me with this problem.

我正在将值插入Sqlite数据库.

I'm inserting values to my Sqlite database.

如何检查或查看插入的数据.

How can I check or view the inserted data.

是否有任何工具或其他技术来显示数据?

Is there is any tool or other techniques to show the data ?

推荐答案

适用于android应用程序的最佳Sqlite调试工具是

The best Sqlite debugging tool for android application is

Stetho 通过Facebook

Stetho By Facebook

http://facebook.github.io/stetho/

Stetho是适用于Android应用程序的复杂调试桥.启用后,开发人员可以访问Chrome桌面浏览器本身的Chrome开发者工具功能.开发人员还可以选择启用可选的dumpapp工具,该工具为应用程序内部提供了强大的命令行界面.

Stetho is a sophisticated debug bridge for Android applications. When enabled, developers have access to the Chrome Developer Tools feature natively part of the Chrome desktop browser. Developers can also choose to enable the optional dumpapp tool which offers a powerful command-line interface to application internals.

下载或者,您可以通过Gradle或Maven从Maven Central包含Stetho.

Download or Alternatively you can include Stetho from Maven Central via Gradle or Maven.

 // Gradle dependency on Stetho 
  dependencies { 
    compile 'com.facebook.stetho:stetho:1.5.1' 
  } 
  <dependency>
    <groupid>com.facebook.stetho</groupid> 
    <artifactid>stetho</artifactid> 
    <version>1.5.1</version> 
  </dependency> 

仅严格要求主要的Stetho依赖关系,但是您可能还希望使用网络助手之一:

Only the main stetho dependency is strictly required, however you may also wish to use one of the network helpers:

    dependencies { 
        compile 'com.facebook.stetho:stetho-okhttp3:1.5.1' 
      } 

 dependencies { 
    compile 'com.facebook.stetho:stetho-okhttp:1.5.1' 
  } 

 dependencies { 
    compile 'com.facebook.stetho:stetho-urlconnection:1.5.1' 
  }

集成

设置

与Stetho集成旨在使大多数现有的Android应用程序无缝且直接. Application class:

Integrating with Stetho is intended to be seamless and straightforward for most existing Android applications. There is a simple initialization step which occurs in your Application class:

public class MyApplication extends Application {
  public void onCreate() {
    super.onCreate();
    Stetho.initializeWithDefaults(this);
  }
}

这会调出大多数默认配置,但不会启用某些其他挂钩(最值得注意的是网络检查).有关各个子系统的详细信息,请参见下文.

This brings up most of the default configuration but does not enable some additional hooks (most notably, network inspection). See below for specific details on individual subsystems.

Enable Network Inspection

如果您正在使用2.2.x +或3.x发行版中流行的OkHttp库,则可以使用Interceptors系统自动挂钩到现有堆栈中.这是目前启用网络检查的最简单,最直接的方法.

If you are using the popular OkHttp library at the 2.2.x+ or 3.x release, you can use the Interceptors system to automatically hook into your existing stack. This is currently the simplest and most straightforward way to enable network inspection.

对于OkHttp 2.x

OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(new StethoInterceptor());

对于OkHttp 3.x

 new OkHttpClient.Builder()
        .addNetworkInterceptor(new StethoInterceptor())
        .build();

由于拦截器可以修改请求和响应,因此请在所有其他拦截器之后添加Stetho拦截器,以准确了解网络流量.

As interceptors can modify the request and response, add the Stetho interceptor after all others to get an accurate view of the network traffic.

如果您使用的是HttpURLConnection,则可以使用StethoURLConnectionManager来协助集成,尽管您应该知道这种方法存在一些警告.特别是,必须明确地在请求标头中添加Accept-Encoding: gzip并手动处理压缩的响应,以便Stetho报告压缩的有效负载大小.

If you are using HttpURLConnection, you can use StethoURLConnectionManager to assist with integration though you should be aware that there are some caveats with this approach. In particular, you must explicitly add Accept-Encoding: gzip to the request headers and manually handle compressed responses in order for Stetho to report compressed payload sizes.

有关更多信息,请访问 stetho

for more info please visit stetho

这篇关于如何在Android Studio上获取Sqlite数据库中插入数据的实时视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆