List of usage examples for android.database Cursor moveToFirst
boolean moveToFirst();
From source file:Main.java
public static java.util.List<String> getLabelsFromInt(Cursor c) { c.moveToFirst(); ArrayList<String> res = new ArrayList<>(); for (int i = 0; i < c.getCount(); i++) { res.add(i, String.valueOf(c.getInt(0))); c.moveToNext();/*from w w w . ja va 2 s .c om*/ } return res; }
From source file:Main.java
private static int processIntCursor(final Cursor cursor) { if (cursor.moveToFirst()) { return cursor.getInt(0); }// w w w .jav a 2s . c o m return 0; }
From source file:Main.java
public static int getNbEspece(SQLiteDatabase db) { Cursor res = db.rawQuery("SELECT count(*) FROM espece", null); res.moveToFirst(); return res.getInt(0); }
From source file:Main.java
public static int getNbTravail(SQLiteDatabase db) { Cursor res = db.rawQuery("SELECT count(*) FROM travail", null); res.moveToFirst(); return res.getInt(0); }
From source file:Main.java
public static boolean checkCursor(Cursor cur) { if (cur == null) return false; if (!cur.moveToFirst()) { cur.close();//from ww w .j a v a 2 s . c o m return false; } return true; }
From source file:Main.java
public static int queryCount(SQLiteDatabase db, String tableName, String where, String[] whereArgs) { StringBuffer stringBuffer = new StringBuffer("select count(*) from "); stringBuffer.append(tableName);//w ww . j ava 2 s . co m if (where != null) { stringBuffer.append(" where "); stringBuffer.append(where); } Cursor cursor = db.rawQuery(stringBuffer.toString(), whereArgs); cursor.moveToFirst(); int count = cursor.getInt(0); cursor.close(); return count; }
From source file:Main.java
public static int getGroupCount(SQLiteDatabase db) { int result = 0; // SQLiteDatabase db = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READONLY); Cursor cursor = db.rawQuery("select count(*) from classlist;", null); cursor.moveToFirst(); result = cursor.getInt(0);//from w w w . j a v a 2 s. c o m cursor.close(); // db.close(); return result; }
From source file:Main.java
public static String getRealPathFromURI(Context ctx, Uri uri) { Cursor cursor = ctx.getContentResolver().query(uri, null, null, null, null); cursor.moveToFirst(); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); return cursor.getString(idx); }
From source file:Main.java
public static String getRealPathFromURI(Uri uri, Context context) { Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); cursor.moveToFirst(); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); return cursor.getString(idx); }
From source file:Main.java
public static ArrayList<String> cursorToArrayList(Cursor cursor) { ArrayList<String> list = new ArrayList<String>(); cursor.moveToFirst(); while (cursor.isAfterLast() == false) { list.add(cursor.getString(cursor.getColumnIndex("name"))); cursor.moveToNext();// ww w . j av a 2 s . c o m } return list; }