List of usage examples for android.database MatrixCursor moveToFirst
@Override public final boolean moveToFirst()
From source file:com.nextgis.maplibui.control.PhotoGallery.java
public static void getAttaches(IGISApplication app, VectorLayer layer, long featureId, Map<String, Integer> map, boolean excludeSign) { Uri uri = Uri.parse("content://" + app.getAuthority() + "/" + layer.getPath().getName() + "/" + featureId + "/" + Constants.URI_ATTACH); MatrixCursor attachCursor = (MatrixCursor) layer.query(uri, new String[] { VectorLayer.ATTACH_DATA, VectorLayer.ATTACH_ID }, FIELD_ID + " = " + featureId, null, null, null);/*w w w . jav a2 s. c o m*/ if (attachCursor.moveToFirst()) { do { if (excludeSign && attachCursor.getInt(1) == Integer.MAX_VALUE) continue; map.put(attachCursor.getString(0), attachCursor.getInt(1)); } while (attachCursor.moveToNext()); } attachCursor.close(); }
From source file:com.futureplatforms.kirin.test.DatabasesBackendTest_inactive.java
public void testCoerceToJSONObject() throws JSONException { String[] columnNames = new String[] { "foo", "bar", "baz" }; MatrixCursor cursor = new MatrixCursor(columnNames); cursor.addRow(new Object[] { 1, 2, 3 }); cursor.moveToFirst(); JSONObject obj = mBackend.coerceToJSONObject(columnNames, cursor); assertEquals(1, obj.getInt("foo")); assertEquals(2, obj.getInt("bar")); assertEquals(3, obj.getInt("baz")); }
From source file:com.futureplatforms.kirin.test.DatabasesBackendTest_inactive.java
public void testCoerceToJSONArray() throws JSONException { String[] columnNames = new String[] { "foo", "bar", "baz" }; MatrixCursor cursor = new MatrixCursor(columnNames); cursor.addRow(new Object[] { 1, 2, 3 }); cursor.addRow(new Object[] { 4, 5, 6 }); cursor.addRow(new Object[] { 7, 8, 9 }); cursor.moveToFirst(); JSONArray array = mBackend.coerceToJSONArray(columnNames, cursor); assertEquals(3, array.length());/*from w w w .j a va 2s. com*/ JSONObject obj = array.getJSONObject(0); assertEquals(1, obj.getInt("foo")); assertEquals(2, obj.getInt("bar")); assertEquals(3, obj.getInt("baz")); obj = array.getJSONObject(1); assertEquals(4, obj.getInt("foo")); assertEquals(5, obj.getInt("bar")); assertEquals(6, obj.getInt("baz")); obj = array.getJSONObject(2); assertEquals(7, obj.getInt("foo")); assertEquals(8, obj.getInt("bar")); assertEquals(9, obj.getInt("baz")); }
From source file:com.av.remusic.service.MediaService.java
private void updateCursor(final long trackId) { MusicInfo info = mPlaylistInfo.get(trackId); if (mPlaylistInfo.get(trackId) != null) { MatrixCursor cursor = new MatrixCursor(PROJECTION); cursor.addRow(new Object[] { info.songId, info.artist, info.albumName, info.musicName, info.data, info.albumData, info.albumId, info.artistId }); cursor.moveToFirst(); mCursor = cursor;/*from w w w. j a v a2s .c o m*/ cursor.close(); } }