use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class GPXDatabase method remove.
public boolean remove(File file) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
String fileName = getFileName(file);
String fileDir = getFileDir(file);
db.execSQL("DELETE FROM " + GPX_TABLE_NAME + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", new Object[] { fileName, fileDir });
} finally {
db.close();
}
return true;
}
return false;
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class FavouritesDbHelper method loadAndCheckDatabasePoints.
private void loadAndCheckDatabasePoints() {
if (favoriteGroups == null) {
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"SELECT " + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", " + FAVOURITE_COL_LAT + "," + FAVOURITE_COL_LON + " FROM " + FAVOURITE_TABLE_NAME, null);
cachedFavoritePoints.clear();
if (query.moveToFirst()) {
do {
String name = query.getString(0);
String cat = query.getString(1);
FavouritePoint p = new FavouritePoint();
p.setName(name);
p.setCategory(cat);
FavoriteGroup group = getOrCreateGroup(p, 0);
if (!name.equals("")) {
p.setLatitude(query.getDouble(2));
p.setLongitude(query.getDouble(3));
group.points.add(p);
}
} while (query.moveToNext());
}
query.close();
} finally {
db.close();
}
sortAll();
}
recalculateCachedFavPoints();
}
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class FavouritesDbHelper method deleteFavouriteDB.
public boolean deleteFavouriteDB(FavouritePoint p) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("DELETE FROM " + FAVOURITE_TABLE_NAME + " WHERE category = ? AND " + whereNameLatLon(), // $NON-NLS-1$ //$NON-NLS-2$
new Object[] { p.getCategory(), p.getName(), p.getLatitude(), p.getLongitude() });
FavouritePoint fp = findFavoriteByAllProperties(p.getCategory(), p.getName(), p.getLatitude(), p.getLongitude());
if (fp != null) {
FavoriteGroup group = flatGroups.get(p.getCategory());
if (group != null) {
group.points.remove(fp);
}
cachedFavoritePoints.remove(fp);
}
saveCurrentPointsIntoFile();
} finally {
db.close();
}
return true;
}
return false;
}
use of net.osmand.plus.api.SQLiteAPI.SQLiteConnection in project Osmand by osmandapp.
the class WikivoyageDbHelper method getArticle.
@Nullable
public WikivoyageArticle getArticle(long cityId, String lang) {
WikivoyageArticle res = null;
SQLiteConnection conn = openConnection();
if (conn != null) {
try {
SQLiteCursor cursor = conn.rawQuery(ARTICLES_TABLE_SELECT + " WHERE " + ARTICLES_COL_CITY_ID + " = ? AND " + ARTICLES_COL_LANG + " = ?", new String[] { String.valueOf(cityId), lang });
if (cursor.moveToFirst()) {
res = readArticle(cursor);
}
cursor.close();
} finally {
conn.close();
}
}
return res;
}
Aggregations