From efaac44a272e46518f9ff918ae9ae94e55cc7629 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Wed, 6 Jun 2018 22:24:36 +0300 Subject: [PATCH] Add a method to retrieve an article by title and language --- .../plus/wikivoyage/data/TravelDbHelper.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 04f6e1d306..ae839fe201 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -3,6 +3,7 @@ package net.osmand.plus.wikivoyage.data; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; + import net.osmand.Collator; import net.osmand.CollatorStringMatcher; import net.osmand.CollatorStringMatcher.StringMatcherMode; @@ -31,7 +32,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -529,6 +529,23 @@ public class TravelDbHelper { return res; } + @Nullable + public TravelArticle getArticle(String title, String lang) { + TravelArticle res = null; + SQLiteConnection conn = openConnection(); + if (conn != null) { + SQLiteCursor cursor = conn.rawQuery(ARTICLES_TABLE_SELECT + " WHERE " + ARTICLES_COL_TITLE + " = ? AND " + + ARTICLES_COL_LANG + " = ?", new String[]{title, lang}); + if (cursor != null) { + if (cursor.moveToFirst()) { + res = readArticle(cursor); + } + cursor.close(); + } + } + return res; + } + public long getArticleId(String title, String lang) { long res = 0; SQLiteConnection conn = openConnection();