public class AdBlocker {
    private static final String AD_HOSTS_FILE = "ads_website.txt";
    private static final Set<String> AD_HOSTS = new HashSet<>();
	
    public static void init(final Context context) {
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                try {
                    loadFromAssets(context);
                } catch (IOException e) {
                    // …
                }
                return null;
            }
        }.execute();
    }

    private static void loadFromAssets(Context context) throws IOException {
        InputStream stream = context.getAssets().open(AD_HOSTS_FILE);
        BufferedSource buffer = Okio.buffer(Okio.source(stream));
        String line;

        while ((line = buffer.readUtf8Line()) != null) {
            AD_HOSTS.add(line);
        }

        buffer.close();
        stream.close();
    }
}

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ssaurel.adblocker">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:name=".MyApplication">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

package com.ssaurel.adblocker;

import android.app.Application;

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        AdBlocker.init(this);
    }
}

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.ssaurel.adblocker.MainActivity">

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</RelativeLayout>

package com.ssaurel.adblocker;

import android.support.v7.app.AppCompatActivity;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {

    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView = (WebView) findViewById(R.id.webView);
        webView.setWebViewClient(new WebViewClient());
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("https://www.ssaurel.com/blog");
    }
}

webView.setWebViewClient(new WebViewClient() {
  private Map<String, Boolean> loadedUrls = new HashMap<>();

  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    boolean ad = false;

	if (!loadedUrls.containsKey(url)) {
	  ad = AdBlocker.isAd(url);
	  loadedUrls.put(url, ad);
	} else {
	  ad = loadedUrls.get(url);
	}

	if (ad) {
	  Log.i("MyAdBlocker", "Blocked Url Ad = " + url);
	}

	return ad ? AdBlocker.createEmptyResource() :
			super.shouldInterceptRequest(view, url);
  }
});

public static boolean isAd(String url) {
   HttpUrl httpUrl = HttpUrl.parse(url);
   return isAdHost(httpUrl != null ? httpUrl.host() : "");
}

private static boolean isAdHost(String host) {
   if (TextUtils.isEmpty(host)) {
      return false;
   }

   int index = host.indexOf(".");
   return index >= 0 && (AD_HOSTS.contains(host) ||
	index + 1 < host.length() && isAdHost(host.substring(index + 1)));
}