List of usage examples for android.database Cursor getInt
int getInt(int columnIndex);
From source file:Main.java
public static int getCursorInt(Cursor cursor, String name) { if (isCursorEmpty(cursor)) { return 0; } else {// www .ja v a 2 s. c o m return cursor.getInt(cursor.getColumnIndex(name)); } }
From source file:Main.java
public static boolean boolFromCursor(Cursor c, String field) { if (c.isNull(c.getColumnIndex(field))) { return false; }/* w w w . j a v a 2 s. co m*/ int val = c.getInt(c.getColumnIndex(field)); return (val > 0) ? true : false; }
From source file:Main.java
public static void keep_setInt(Field field, Object obj, Cursor cursor, int i) { try {//from ww w . ja v a 2 s .co m if (field.getType().equals(Integer.TYPE)) field.setInt(obj, cursor.getInt(i)); else field.set(obj, Integer.valueOf(cursor.getInt(i))); } catch (Exception exception) { exception.printStackTrace(); } }
From source file:Main.java
public static Boolean gBoolean(Cursor cursor, String columeName) { Boolean val = null; if (cursor.getColumnIndex(columeName) != -1) { val = cursor.getInt(cursor.getColumnIndex(columeName)) > 0; }/* w ww . j a v a 2s . co m*/ return val; }
From source file:Main.java
public static Integer gInt(Cursor cursor, String columeName) { Integer val = null; if (cursor.getColumnIndex(columeName) != -1) { val = cursor.getInt(cursor.getColumnIndex(columeName)); }// w w w .j av a 2 s. c o m return val; }
From source file:Main.java
public static void removeFromPlaylist(ContentResolver resolver, int audioId, long playlistId) { String[] cols = new String[] { "count(*)" }; Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId); Cursor cur = resolver.query(uri, cols, null, null, null); cur.moveToFirst();//from w ww. jav a 2 s . co m final int base = cur.getInt(0); cur.close(); ContentValues values = new ContentValues(); resolver.delete(uri, MediaStore.Audio.Playlists.Members.AUDIO_ID + "=" + audioId, null); }
From source file:Main.java
public static void addToMediaStorePlaylist(ContentResolver resolver, int audioId, long playlistId) { String[] cols = new String[] { "count(*)" }; Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId); Cursor cur = resolver.query(uri, cols, null, null, null); cur.moveToFirst();//from w w w. j a v a 2 s .co m final int base = cur.getInt(0); cur.close(); ContentValues values = new ContentValues(); values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, Integer.valueOf(base + audioId)); values.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, audioId); resolver.insert(uri, values); }
From source file:Main.java
private static int getInt(final Cursor cursor, final String field, final int defValue) { if (cursor.getColumnIndex(field) >= 0) { return cursor.getInt(cursor.getColumnIndex(field)); } else {/*from w ww. jav a 2 s. c o m*/ return defValue; } }
From source file:Main.java
public static SparseIntArray readCountArray(Cursor cursor) { SparseIntArray countMap = new SparseIntArray(); while (cursor.moveToNext()) { countMap.put(cursor.getInt(ID_INDEX), cursor.getInt(TASK_COUNT_INDEX)); }//from ww w . j a v a 2 s .co m return countMap; }
From source file:Main.java
/** * Get the cursor//from w w w . jav a2s. c o m * @param cursor Cursor from where read value * @param index int to read * @return Object read */ private static Object getCursorValue(Cursor cursor, int index) { switch (cursor.getType(index)) { case Cursor.FIELD_TYPE_INTEGER: return Integer.valueOf(cursor.getInt(index)); case Cursor.FIELD_TYPE_FLOAT: return Float.valueOf(cursor.getFloat(index)); case Cursor.FIELD_TYPE_STRING: return cursor.getString(index); case Cursor.FIELD_TYPE_BLOB: return cursor.getBlob(index); default: return null; } }