title: WebView implementation with Firebase Database in Android
body: <p>I want to implement <strong>webView</strong> with <strong>Firebase</strong> so that if I add a <strong>URL</strong> in <strong>firebase Database</strong> it gets implemented on my webView <strong>in application</strong> in <strong>realtime</strong>, I have successfully implemented the text and images through database but could not get webView work correctly, I have searched many options but neither work for me, please help. If you want any more detail I can provide you.</p>
  
  <blockquote>
    <p>I am using Android Studio</p>
  </blockquote>
  
  <p><strong>Below is my Java class code for Firebase implementation for Images and text</strong></p>
  
  <pre><code>@Override
      public void onStart() {
          super.onStart();
          FirebaseUser currentUser = mAuth.getCurrentUser();
          if (currentUser == null) {
              sentToStart();
          }
          FirebaseRecyclerAdapter &lt;post, postViewHolder&gt; firebaseRecyclerAdapter = new FirebaseRecyclerAdapter&lt;post, postViewHolder&gt;(
  
              post.class,
              R.layout.post_row_recycle_home,
              postViewHolder.class,
              mDatabaseReference
      ) {
          @Override
          protected void populateViewHolder(postViewHolder viewHolder, post model, int position) {
              viewHolder.setTitle(model.getTitle());
              viewHolder.setdescription(model.getDescription());
              viewHolder.setimage(getApplicationContext(), model.getImage());
              viewHolder.setsource(model.getSource());
          }
      };
      mrecyclerView.setAdapter(firebaseRecyclerAdapter);
  }
  public static class postViewHolder extends RecyclerViewPager.ViewHolder{
  
      View mView;
  
      public postViewHolder(View itemView) {
          super(itemView);
          mView = itemView;
      }
  
      public void setTitle(String title){
          TextView post_title = (TextView)mView.findViewById(R.id.title_cardView);
          post_title.setText(title);
      }
      public void setsource(String source){
          TextView post_source = (TextView)mView.findViewById(R.id.source_cardView);
          post_source.setText(source);
      }
  
      public void setdescription(String description){
          TextView post_description = (TextView)mView.findViewById(R.id.description_cardView);
          post_description.setText(description);
      }
  
      public void setimage(final Context ctx, final String image){
          final ImageView post_image = (ImageView)mView.findViewById(R.id.post_image);
          Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(post_image, new Callback() {
  
              @Override
              public void onSuccess() {
              }
              @Override
              public void onError() {
                  Picasso.with(ctx).load(image).into(post_image);
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>Getter/Setter Java Class</strong></p>
  
  <pre><code>public class post {
  
      private String title;
      private String description;
      private String image;
      private String source;
  
  
  
      public String getSource() {
          return source;
      }
  
      public void setSource(String source) {
          this.source = source;
      }
  
      public post(){
      }
  
      public post(String title, String description, String image, String source) {
          this.title = title;
          this.description = description;
          this.image = image;
          this.source = source;
      }
  
      public String getTitle() {
          return title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public String getImage() {
          return image;
      }
  
      public void setImage(String image) {
          this.image = image;
      }
  
  }
  </code></pre>
  
  <p><strong>Updated: WebView java Activity</strong> </p>
  
  <pre><code>public class webViewNews extends AppCompatActivity {
  
      private WebView webviewthis;
      private DatabaseReference mDatabaseReference;
      private DatabaseReference mdataRef;
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.webview_page);
          mdataRef = FirebaseDatabase.getInstance().getReference().child("webView");
          webviewthis = (WebView)findViewById(R.id.webView_news);
          webviewthis.setWebViewClient(new WebViewClient());
          webviewthis.getSettings().setJavaScriptEnabled(true);
          webviewthis.getSettings().setLoadsImagesAutomatically(true);
  
  
          mdataRef.child("webView").addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                      dataSnapshot.child("webView").getValue();
                      webviewthis.loadUrl("");
  
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          });
  
      }
      @Override
      protected void onStart() {
          super.onStart();
          }
  }
  </code></pre>