Example usage for android.database Cursor getInt

List of usage examples for android.database Cursor getInt

Introduction

In this page you can find the example usage for android.database Cursor getInt.

Prototype

int getInt(int columnIndex);

Source Link

Document

Returns the value of the requested column as an int.

Usage

From source file:com.panoskrt.dbadapter.DBAdapter.java

public int getIntEntry(String column, String table, String match) {
    int number = 0;
    Cursor c = database.rawQuery("SELECT " + column + " FROM " + table + " WHERE " + column + "=" + match,
            null);//from  w  w w . j a va2  s .c  o m
    if (c != null) {
        if (c.moveToFirst()) {
            number = c.getInt(c.getColumnIndex(column));
        }
    }
    return number;
}

From source file:com.panoskrt.dbadapter.DBAdapter.java

public long getLongEntry(String column, String table, String match) {
    long number = 0;
    Cursor c = database.rawQuery("SELECT " + column + " FROM " + table + " WHERE " + column + "=" + match,
            null);//from  w w w  .  j  av a2 s.  co m
    if (c != null) {
        if (c.moveToFirst()) {
            number = c.getInt(c.getColumnIndex(column));
        }
    }
    return number;
}

From source file:com.panoskrt.dbadapter.DBAdapter.java

public double getDoubleEntry(String column, String table, String match) {
    double number = 0;
    Cursor c = database.rawQuery("SELECT " + column + " FROM " + table + " WHERE " + column + "=" + match,
            null);//from  w w  w  . ja  v  a 2 s  .  c o m
    if (c != null) {
        if (c.moveToFirst()) {
            number = c.getInt(c.getColumnIndex(column));
        }
    }
    return number;
}

From source file:net.naonedbus.manager.impl.FavoriManager.java

@Override
public Favori getSingleFromCursor(final Cursor c) {
    mBuilder.setId(c.getInt(c.getColumnIndex(FavoriTable._ID)));
    mBuilder.setCodeLigne(c.getString(c.getColumnIndex(FavoriTable.CODE_LIGNE)));
    mBuilder.setCodeSens(c.getString(c.getColumnIndex(FavoriTable.CODE_SENS)));
    mBuilder.setCodeArret(c.getString(c.getColumnIndex(FavoriTable.CODE_ARRET)));
    mBuilder.setNomArret(c.getString(c.getColumnIndex(FavoriTable.NOM)));

    mBuilder.setNomFavori(null);//  w ww. j av  a2  s  .  co  m
    mBuilder.setCouleurBackground(0);
    mBuilder.setCouleurTexte(0);
    mBuilder.setNomSens(null);
    mBuilder.setLettre(null);

    return mBuilder.build();
}

From source file:net.naonedbus.manager.impl.FavoriManager.java

public Favori getSingleFromCursorFull(final Cursor c) {
    mBuilder.setId(c.getInt(c.getColumnIndex(FavoriTable._ID)));
    mBuilder.setCodeLigne(c.getString(c.getColumnIndex(FavoriTable.CODE_LIGNE)));
    mBuilder.setCodeSens(c.getString(c.getColumnIndex(FavoriTable.CODE_SENS)));
    mBuilder.setCodeArret(c.getString(c.getColumnIndex(FavoriTable.CODE_ARRET)));
    mBuilder.setNomFavori(c.getString(c.getColumnIndex(FavoriTable.NOM)));
    mBuilder.setNomArret(c.getString(c.getColumnIndex(EquipementTable.NOM)));

    final int couleurBackground = c.getInt(c.getColumnIndex(LigneTable.COULEUR_BACK));
    final int couleurFront = c.getInt(c.getColumnIndex(LigneTable.COULEUR_FRONT));
    mBuilder.setCouleurBackground(couleurBackground);
    mBuilder.setCouleurTexte(couleurFront);

    mBuilder.setNomSens(c.getString(c.getColumnIndex(SensTable.NOM)));
    mBuilder.setLettre(c.getString(c.getColumnIndex(LigneTable.LETTRE)));
    return mBuilder.build();
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.database.SignDAO.java

private Sign cursorToSign(Cursor cursor) {
    final Sign.Builder signBuilder = new Sign.Builder();
    signBuilder.setId(cursor.getInt(cursor.getColumnIndex(DbContract.SignTable._ID)));
    signBuilder.setName(cursor.getString(cursor.getColumnIndex(DbContract.SignTable.COLUMN_NAME_SIGN_NAME)));
    signBuilder.setNameLocaleDe(/*from   w w  w .  j  a va2 s . c  o m*/
            cursor.getString(cursor.getColumnIndex(DbContract.SignTable.COLUMN_NAME_SIGN_NAME_DE)));
    signBuilder.setMnemonic(cursor.getString(cursor.getColumnIndex(DbContract.SignTable.COLUMN_NAME_MNEMONIC)));
    signBuilder.setLearningProgress(
            cursor.getInt(cursor.getColumnIndex(DbContract.SignTable.COLUMN_NAME_LEARNING_PROGRESS)));
    final int starred = cursor.getInt(cursor.getColumnIndex(DbContract.SignTable.COLUMN_NAME_STARRED));
    if (1 == starred) {
        signBuilder.setStarred(true);
    } else {
        signBuilder.setStarred(false);
    }
    return signBuilder.create();
}

From source file:com.manning.androidhacks.hack023.dao.TodoDAO.java

private List<Todo> getTodosWithSelection(ContentResolver contentResolver, String selection) {
    Cursor cursor = contentResolver.query(TodoContentProvider.CONTENT_URI, null, selection, null, null);

    List<Todo> list = new ArrayList<Todo>();

    while (cursor.moveToNext()) {
        int localId = cursor.getInt(cursor.getColumnIndexOrThrow(TodoContentProvider.COLUMN_ID));
        int serverId = cursor.getInt(cursor.getColumnIndexOrThrow(TodoContentProvider.COLUMN_SERVER_ID));
        String name = cursor.getString(cursor.getColumnIndexOrThrow(TodoContentProvider.COLUMN_TITLE));
        int status = cursor.getInt(cursor.getColumnIndexOrThrow(TodoContentProvider.COLUMN_STATUS_FLAG));

        Todo currentTodo = new Todo();

        if (status == StatusFlag.ADD) {
            currentTodo.setId((long) localId);
        } else {/*from  w w w .j  ava  2  s .  co m*/
            currentTodo.setId((long) serverId);
        }
        currentTodo.setTitle(name);
        currentTodo.setStatus(status);

        list.add(currentTodo);
    }

    cursor.close();
    return list;
}

From source file:com.taxicop.sync.SyncAdapter.java

public int queryLastId(ContentProviderClient provider) {
    Cursor c = null;
    int id = 0;//from  w ww  .  j  a va  2s.  c  o m
    try {
        c = provider.query(PlateContentProvider.URI_USERS, null, null, null, null);
        if (c.moveToFirst())
            id = c.getInt(c.getColumnIndex(Fields.ITH));

    } catch (Exception e) {
        Log.e(TAG, "lastId= " + e.getMessage());
    }
    c.close();
    return id;
}

From source file:com.manning.androidhacks.hack023.dao.TodoDAO.java

public int getTodoStatus(ContentResolver contentResolver, Long id) {
    Cursor c = contentResolver.query(TodoContentProvider.CONTENT_URI, null,
            TodoContentProvider.COLUMN_ID + "=" + id, null, null);

    int status = 0;

    try {//from  w  w w. j a  va2 s . c  om
        if (c.moveToNext()) {
            status = c.getInt(c.getColumnIndexOrThrow(TodoContentProvider.COLUMN_STATUS_FLAG));

        } else {
            throw new RuntimeException("Tried to delete a non existent todo");
        }
    } finally {
        c.close();
    }

    return status;
}

From source file:com.ruuhkis.cookies.CookieSQLSource.java

private int[] getPorts(long cookieId) {
    List<Integer> ports = new ArrayList<Integer>();

    Cursor cursor = db.query(CookieSQLHelper.PORT_TABLE_NAME, null, CookieSQLHelper.COLUMN_COOKIE_ID + "=?",
            new String[] { Long.toString(cookieId) }, null, null, null, null);
    cursor.moveToFirst();/*from  ww w  .j a v a  2 s.  co m*/

    while (!cursor.isAfterLast()) {
        ports.add(cursor.getInt(cursor.getColumnIndex(CookieSQLHelper.COLUMN_PORT)));
        cursor.moveToNext();
    }

    cursor.close();

    int[] arrayPorts = new int[ports.size()];
    for (int i = 0; i < ports.size(); i++) {
        arrayPorts[i] = ports.get(i);
    }

    return arrayPorts;
}