List of usage examples for android.database Cursor getInt
int getInt(int columnIndex);
From source file:Main.java
public static ArrayList<ContentValues> getCity(SQLiteDatabase db, int dqx_dqxx01, boolean municipalities) { ArrayList<ContentValues> list = new ArrayList<ContentValues>(); ContentValues values = null;/*w w w . j a v a 2 s . co m*/ Cursor cursor = db.query(TABLE_NAME, new String[] { "DQXX01", "DQXX02" }, "DQX_DQXX01=?", new String[] { "" + dqx_dqxx01 }, null, null, "DQXX01 ASC"); if (cursor != null) { if (municipalities) { cursor.moveToNext(); } while (cursor.moveToNext()) { values = new ContentValues(); values.put("city_id", cursor.getInt(0)); values.put("city", cursor.getString(1)); list.add(values); } } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return list; }
From source file:com.example.facebook_photo.Utility.java
public static int getOrientation(Context context, Uri photoUri) { /* it's on the external media. */ Cursor cursor = context.getContentResolver().query(photoUri, new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null); if (cursor.getCount() != 1) { return -1; }/* www . java 2 s . c o m*/ cursor.moveToFirst(); int orientation = cursor.getInt(0); cursor.close(); return orientation; }
From source file:Main.java
private static Bitmap rotateMediaImage(ContentResolver contentResolver, Uri uri, Bitmap image) throws FileNotFoundException { Cursor c = contentResolver.query(uri, null, null, null, null); try {//w ww . j av a2 s . com if (c != null) { if (c.moveToFirst()) { int index = c.getColumnIndex(ImageColumns.ORIENTATION); int degrees = index < 0 ? 0 : c.getInt(index); if (degrees != 0) { return rotate(image, degrees); } return image; } } } finally { if (c != null) { c.close(); } } return image; }
From source file:Main.java
/** * Returns the ID for an album.//from w w w . ja v a2 s. c o m * * @param context The {@link Context} to use. * @param albumName The name of the album. * @param artistName The name of the artist * @return The ID for an album. */ public static final long getIdForAlbum(final Context context, final String albumName, final String artistName) { Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, new String[] { BaseColumns._ID }, AlbumColumns.ALBUM + "=? AND " + AlbumColumns.ARTIST + "=?", new String[] { albumName, artistName }, AlbumColumns.ALBUM); int id = -1; if (cursor != null) { cursor.moveToFirst(); if (!cursor.isAfterLast()) { id = cursor.getInt(0); } cursor.close(); cursor = null; } return id; }
From source file:Main.java
public static int getStatus(Context context) { Cursor query = null; String packageName = context.getPackageName(); try {// w w w . j ava 2s . co m query = context.getContentResolver().query(Uri.parse("content://com.lbe.security.miui.permmgr/active"), null, "pkgName=?", new String[] { packageName }, null); if (query == null) { return 0; } if (query.moveToFirst()) { int status = query.getInt(query.getColumnIndex("userAccept")); if (query == null) { return status; } } query.close(); } catch (Exception e) { return -1; } return -1; }
From source file:Main.java
public static Map<Integer, List> getCityByPid(int id, File file) { String sql = "select cityid,city from city where provinceid= " + id; SQLiteDatabase db = null;//from ww w.j av a 2 s. c o m Cursor c = null; Map<Integer, List> cityData = new HashMap<Integer, List>(); //List cityList = null; try { db = SQLiteDatabase.openOrCreateDatabase(file, null); c = db.rawQuery(sql, null); List cityList1 = new ArrayList(); List cityList2 = new ArrayList(); while (c.moveToNext()) { Map cityMap = new HashMap(); cityMap.put(c.getString(1), c.getInt(0)); cityList1.add(cityMap); cityList2.add(c.getString(1)); } cityData.put(0, cityList1); cityData.put(1, cityList2); } catch (Exception e) { Log.d("WineStock", "getCityByPid:" + e.getMessage()); } finally { if (c != null) { c.close(); } if (db != null) { db.close(); } } return cityData; }
From source file:com.fanfou.app.opensource.api.ApiParser.java
public static boolean parseBoolean(final Cursor c, final String columnName) { return c.getInt(c.getColumnIndex(columnName)) == 1; }
From source file:com.fanfou.app.opensource.api.ApiParser.java
public static int parseInt(final Cursor c, final String columnName) { return c.getInt(c.getColumnIndex(columnName)); }
From source file:com.xfinity.ceylon_steel.controller.CustomerController.java
public static ArrayList<Customer> getCustomers(Context context) { ArrayList<Customer> customers = new ArrayList<Customer>(); SQLiteDatabaseHelper databaseInstance = SQLiteDatabaseHelper.getDatabaseInstance(context); SQLiteDatabase database = databaseInstance.getWritableDatabase(); Cursor customerCursor = database.rawQuery("select customerId, customerName from tbl_customer", null); int customerIdIndex = customerCursor.getColumnIndex("customerId"); int customerNameIndex = customerCursor.getColumnIndex("customerName"); for (customerCursor.moveToFirst(); !customerCursor.isAfterLast(); customerCursor.moveToNext()) { Customer customer = new Customer(customerCursor.getInt(customerIdIndex), customerCursor.getString(customerNameIndex)); customers.add(customer);//w w w . j av a2 s.co m } customerCursor.close(); databaseInstance.close(); return customers; }
From source file:Main.java
public static Map<Integer, List> getProvince(File file) { String sql = "select provinceid ,province from province "; SQLiteDatabase db = null;/*from www . ja v a 2 s . c o m*/ Cursor c = null; Map<Integer, List> provinceData = new HashMap<Integer, List>(); //List provinceList = null; try { db = SQLiteDatabase.openOrCreateDatabase(file, null); c = db.rawQuery(sql, null); List provinceList1 = new ArrayList(); List provinceList2 = new ArrayList(); while (c.moveToNext()) { Map provinceMap = new HashMap(); provinceMap.put(c.getString(1), c.getInt(0)); provinceList1.add(provinceMap); provinceList2.add(c.getString(1)); } provinceData.put(0, provinceList1); provinceData.put(1, provinceList2); } catch (Exception e) { Log.d("WineStock", "getProvince:" + e.getMessage()); } finally { if (c != null) { c.close(); } if (db != null) { db.close(); } } return provinceData; }