public List<Pair<String, String>> getAll() {
    List<Pair<String, String>> result = new ArrayList<>();

    Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_HOSTS + ";", null);
    try {
      while (cursor.moveToNext()) {
        String host = SqlUtils.getString(cursor, COLUMN_HOST, null);
        String ip = SqlUtils.getString(cursor, COLUMN_IP, null);

        InetAddress inetAddress = toInetAddress(host, ip);
        if (inetAddress == null) {
          continue;
        }

        result.add(new Pair<>(host, ip));
      }
    } finally {
      cursor.close();
    }

    return result;
  }
@Test
  public void testGetAll() {
    Hosts hosts = new Hosts(RuntimeEnvironment.application, "hosts.db");

    List<Pair<String, String>> all = hosts.getAll();
    assertEquals(0, all.size());

    hosts.put("ni.hao", "127.0.0.1");
    hosts.put("wo.hao", "127.0.0.2");

    all = hosts.getAll();
    assertEquals(2, all.size());

    assertEquals("ni.hao", all.get(0).first);
    assertEquals("127.0.0.1", all.get(0).second);
    assertEquals("wo.hao", all.get(1).first);
    assertEquals("127.0.0.2", all.get(1).second);
  }