Search in sources :

Example 6 with SQLiteCursor

use of net.osmand.plus.api.SQLiteAPI.SQLiteCursor in project Osmand by osmandapp.

the class MapMarkersDbHelper method getMarkersHistory.

public List<MapMarker> getMarkersHistory() {
    List<MapMarker> markers = new ArrayList<>();
    SQLiteConnection db = openConnection(true);
    if (db != null) {
        try {
            SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?", new String[] { String.valueOf(0) });
            if (query.moveToFirst()) {
                do {
                    markers.add(readItem(query));
                } while (query.moveToNext());
            }
            query.close();
        } finally {
            db.close();
        }
    }
    return markers;
}
Also used : MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) SQLiteConnection(net.osmand.plus.api.SQLiteAPI.SQLiteConnection) ArrayList(java.util.ArrayList) SQLiteCursor(net.osmand.plus.api.SQLiteAPI.SQLiteCursor)

Example 7 with SQLiteCursor

use of net.osmand.plus.api.SQLiteAPI.SQLiteCursor in project Osmand by osmandapp.

the class GPXDatabase method getItems.

public List<GpxDataItem> getItems() {
    List<GpxDataItem> items = new ArrayList<>();
    SQLiteConnection db = openConnection(true);
    if (db != null) {
        try {
            SQLiteCursor query = db.rawQuery(GPX_TABLE_SELECT, null);
            if (query.moveToFirst()) {
                do {
                    items.add(readItem(query));
                } while (query.moveToNext());
            }
            query.close();
        } finally {
            db.close();
        }
    }
    return items;
}
Also used : SQLiteConnection(net.osmand.plus.api.SQLiteAPI.SQLiteConnection) ArrayList(java.util.ArrayList) SQLiteCursor(net.osmand.plus.api.SQLiteAPI.SQLiteCursor)

Example 8 with SQLiteCursor

use of net.osmand.plus.api.SQLiteAPI.SQLiteCursor in project Osmand by osmandapp.

the class GPXDatabase method getItem.

@Nullable
public GpxDataItem getItem(File file) {
    GpxDataItem result = null;
    SQLiteConnection db = openConnection(true);
    if (db != null) {
        try {
            String fileName = getFileName(file);
            String fileDir = getFileDir(file);
            SQLiteCursor query = db.rawQuery(GPX_TABLE_SELECT + " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?", new String[] { fileName, fileDir });
            if (query.moveToFirst()) {
                result = readItem(query);
            }
            query.close();
        } finally {
            db.close();
        }
    }
    return result;
}
Also used : SQLiteConnection(net.osmand.plus.api.SQLiteAPI.SQLiteConnection) SQLiteCursor(net.osmand.plus.api.SQLiteAPI.SQLiteCursor) Nullable(android.support.annotation.Nullable)

Example 9 with SQLiteCursor

use of net.osmand.plus.api.SQLiteAPI.SQLiteCursor in project Osmand by osmandapp.

the class MapMarkersDbHelper method getMarker.

@Nullable
public MapMarker getMarker(String id) {
    MapMarker res = null;
    SQLiteConnection db = openConnection(true);
    if (db != null) {
        try {
            SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ID + " = ?", new String[] { id });
            if (query.moveToFirst()) {
                res = readItem(query);
            }
            query.close();
        } finally {
            db.close();
        }
    }
    return res;
}
Also used : MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) SQLiteConnection(net.osmand.plus.api.SQLiteAPI.SQLiteConnection) SQLiteCursor(net.osmand.plus.api.SQLiteAPI.SQLiteCursor) Nullable(android.support.annotation.Nullable)

Example 10 with SQLiteCursor

use of net.osmand.plus.api.SQLiteAPI.SQLiteCursor in project Osmand by osmandapp.

the class MapMarkersDbHelper method getAllGroupsMap.

public Map<String, MapMarkersGroup> getAllGroupsMap() {
    Map<String, MapMarkersGroup> res = new LinkedHashMap<>();
    SQLiteConnection db = openConnection(true);
    if (db != null) {
        try {
            SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT, null);
            if (query.moveToFirst()) {
                do {
                    MapMarkersGroup group = readGroup(query);
                    res.put(group.getId(), group);
                } while (query.moveToNext());
            }
            query.close();
        } finally {
            db.close();
        }
    }
    return res;
}
Also used : SQLiteConnection(net.osmand.plus.api.SQLiteAPI.SQLiteConnection) MapMarkersGroup(net.osmand.plus.MapMarkersHelper.MapMarkersGroup) SQLiteCursor(net.osmand.plus.api.SQLiteAPI.SQLiteCursor) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

SQLiteCursor (net.osmand.plus.api.SQLiteAPI.SQLiteCursor)15 SQLiteConnection (net.osmand.plus.api.SQLiteAPI.SQLiteConnection)12 Nullable (android.support.annotation.Nullable)3 ArrayList (java.util.ArrayList)3 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)3 LinkedHashMap (java.util.LinkedHashMap)2 SQLiteDiskIOException (android.database.sqlite.SQLiteDiskIOException)1 NonNull (android.support.annotation.NonNull)1 HashSet (java.util.HashSet)1 FavouritePoint (net.osmand.data.FavouritePoint)1 QuadRect (net.osmand.data.QuadRect)1 MapMarkersGroup (net.osmand.plus.MapMarkersHelper.MapMarkersGroup)1