Add a method to retrieve an article by title and language
This commit is contained in:
parent
4be4bb5733
commit
efaac44a27
1 changed files with 18 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue