List of usage examples for android.database Cursor getColumnIndex
int getColumnIndex(String columnName);
From source file:com.mobeelizer.mobile.android.types.FileFieldTypeHelper.java
@Override public void setValueFromDatabaseToMap(final Cursor cursor, final Map<String, String> values, final MobeelizerFieldAccessor field, final Map<String, String> options) { int columnIndex = cursor.getColumnIndex(field.getName() + _GUID); if (cursor.isNull(columnIndex)) { values.put(field.getName(), null); } else {//from ww w . j a v a2 s . com try { JSONObject json = new JSONObject(); json.put(JSON_GUID, cursor.getString(columnIndex)); json.put(JSON_NAME, cursor.getString(cursor.getColumnIndex(field.getName() + _NAME))); values.put(field.getName(), json.toString()); } catch (JSONException e) { throw new IllegalStateException(e.getMessage(), e); } } }
From source file:com.remobile.file.ContentFilesystem.java
protected Long lastModifiedDateForCursor(Cursor cursor) { final String[] LOCAL_FILE_PROJECTION = { MediaStore.MediaColumns.DATE_MODIFIED }; int columnIndex = cursor.getColumnIndex(LOCAL_FILE_PROJECTION[0]); if (columnIndex != -1) { String dateStr = cursor.getString(columnIndex); if (dateStr != null) { return Long.parseLong(dateStr); }// w w w .j ava 2 s . co m } return null; }
From source file:cm.aptoide.com.facebook.android.Facebook.java
/** * Get Attribution ID for app install conversion tracking. * @param contentResolver/*from w ww . j av a 2 s . c o m*/ * @return Attribution ID that will be used for conversion tracking. It will be null only if * the user has not installed or logged in to the Facebook app. */ public static String getAttributionId(ContentResolver contentResolver) { String[] projection = { ATTRIBUTION_ID_COLUMN_NAME }; Cursor c = contentResolver.query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null); if (c == null || !c.moveToFirst()) { return null; } String attributionId = c.getString(c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME)); return attributionId; }
From source file:me.kartikarora.transfersh.adapters.FileGridAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { FileItemViewHolder holder = (FileItemViewHolder) view.getTag(); int nameCol = cursor.getColumnIndex(FilesContract.FilesEntry.COLUMN_NAME); int typeCol = cursor.getColumnIndex(FilesContract.FilesEntry.COLUMN_TYPE); int sizeCol = cursor.getColumnIndex(FilesContract.FilesEntry.COLUMN_SIZE); int urlCol = cursor.getColumnIndex(FilesContract.FilesEntry.COLUMN_URL); final String name = cursor.getString(nameCol); final String type = cursor.getString(typeCol); final String size = cursor.getString(sizeCol); final String url = cursor.getString(urlCol); holder.fileNameTextView.setText(name); String ext = FilenameUtils.getExtension(name); int identifier = context.getResources().getIdentifier("t" + ext, "drawable", context.getPackageName()); try {//from www .j av a2 s.co m holder.fileTypeImageView .setImageDrawable(ResourcesCompat.getDrawable(context.getResources(), identifier, null)); } catch (Resources.NotFoundException e) { e.printStackTrace(); holder.fileTypeImageView .setImageDrawable(ResourcesCompat.getDrawable(context.getResources(), R.drawable.tblank, null)); } holder.fileInfoImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String message = "Name: " + name + "\n" + "File type: " + type + "\n" + "URL: " + url; new AlertDialog.Builder(activity).setMessage(message).setPositiveButton(android.R.string.ok, null) .create().show(); } }); holder.fileShareImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { tracker.send( new HitBuilders.EventBuilder().setCategory("Action").setAction("Share : " + url).build()); context.startActivity(new Intent().setAction(Intent.ACTION_SEND).putExtra(Intent.EXTRA_TEXT, url) .setType("text/plain").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }); holder.fileDownloadImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { checkForDownload(name, type, url, view); } }); }
From source file:org.npr.android.news.StationListAdapter.java
public void initializeList(Cursor cursor) { data = new ArrayList<Station>(); while (cursor.moveToNext()) { Station.StationBuilder builder = new Station.StationBuilder( cursor.getString(cursor.getColumnIndex(FavoriteStationsProvider.Items.STATION_ID))); builder.withName(cursor.getString(cursor.getColumnIndex(FavoriteStationsProvider.Items.NAME))); builder.withMarketCity(cursor.getString(cursor.getColumnIndex(FavoriteStationsProvider.Items.MARKET))); builder.withFrequency(/*ww w .ja v a 2 s . c om*/ cursor.getString(cursor.getColumnIndex(FavoriteStationsProvider.Items.FREQUENCY))); builder.withBand(cursor.getString(cursor.getColumnIndex(FavoriteStationsProvider.Items.BAND))); data.add(builder.build()); } }
From source file:com.textuality.lifesaver.Columns.java
private void setColumns(Cursor cursor) { if (columns != null) return;//from w w w . ja va2 s . com columns = new int[names.length]; for (int i = 0; i < names.length; i++) columns[i] = cursor.getColumnIndex(names[i]); }
From source file:com.codebutler.farebot.transit.SuicaTransitData.java
/** * ?????//from www . j a va 2s .c o m * <pre>http:// sourceforge.jp/projects/felicalib/wiki/suica???????</pre> * @param lineCode * @param stationCode * @return ????????0????1?????? */ private static Station getBusStop(int regionCode, int lineCode, int stationCode) { int areaCode = (regionCode >> 6); try { SQLiteDatabase db = FareBotApplication.getInstance().getSuicaDBUtil().openDatabase(); Cursor cursor = db.query(TABLE_IRUCA_STATIONCODE, COLUMNS_IRUCA_STATIONCODE, String.format("%s = ? AND %s = ?", COLUMN_LINECODE, COLUMN_STATIONCODE), new String[] { Integer.toHexString(lineCode), Integer.toHexString(stationCode) }, null, null, COLUMN_ID); if (!cursor.moveToFirst()) { return null; } // FIXME: Figure out a better way to deal with i18n. boolean isJa = Locale.getDefault().getLanguage().equals("ja"); String companyName = cursor .getString(cursor.getColumnIndex(isJa ? COLUMN_COMPANYNAME : COLUMN_COMPANYNAME_EN)); String stationName = cursor .getString(cursor.getColumnIndex(isJa ? COLUMN_STATIONNAME : COLUMN_STATIONNAME_EN)); return new Station(companyName, null, stationName, null, null, null); } catch (Exception e) { Log.e("SuicaStationProvider", "getBusStop() error", e); return null; } }
From source file:com.clevertrail.mobile.Database_SavedTrails.java
public String queueAll() { String[] columns = new String[] { "name", "json" }; Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, null, null, null, null, null); String result = ""; int index_NAME = cursor.getColumnIndex("name"); for (cursor.moveToFirst(); !(cursor.isAfterLast()); cursor.moveToNext()) { result = result + cursor.getString(index_NAME) + "\n"; }//w w w. j av a 2s .c om return result; }
From source file:com.digipom.manteresting.android.adapter.NailCursorAdapter.java
@Override public Cursor swapCursor(Cursor newCursor) { if (newCursor != null) { nailIdColumnIndex = newCursor.getColumnIndex(Nails.NAIL_ID); nailObjectColumnIndex = newCursor.getColumnIndex(Nails.NAIL_JSON); } else {/*from w w w . j a v a2s .c o m*/ nailIdColumnIndex = -1; nailObjectColumnIndex = -1; cachedData.evictAll(); } return super.swapCursor(newCursor); }
From source file:br.ufc.mdcc.mpos.persistence.ProfileNetworkDao.java
private ArrayList<Network> getLastResults(String sql) throws JSONException, ParseException { openDatabase();//from w w w. j a v a 2s . c om Cursor cursor = database.rawQuery(sql, null); ArrayList<Network> lista = new ArrayList<Network>(15); // obtem todos os indices das colunas da tabela int idx_loss = cursor.getColumnIndex(F_LOSS); int idx_jitter = cursor.getColumnIndex(F_JITTER); int idx_udp = cursor.getColumnIndex(F_UDP); int idx_tcp = cursor.getColumnIndex(F_TCP); int idx_down = cursor.getColumnIndex(F_DOWN); int idx_up = cursor.getColumnIndex(F_UP); int idx_net_type = cursor.getColumnIndex(F_NET_TYPE); int idx_endpoint_type = cursor.getColumnIndex(F_ENDPOINT_TYPE); int idx_date = cursor.getColumnIndex(F_DATE); if (cursor != null && cursor.moveToFirst()) { do { Network network = new Network(); network.setJitter(cursor.getInt(idx_jitter)); network.setLossPacket(cursor.getInt(idx_loss)); network.setBandwidthDownload(cursor.getString(idx_down)); network.setBandwidthUpload(cursor.getString(idx_up)); network.setResultPingTcp(Network.stringToLongArray(cursor.getString(idx_tcp))); network.setResultPingUdp(Network.stringToLongArray(cursor.getString(idx_udp))); network.setEndpointType(cursor.getString(idx_endpoint_type)); network.setNetworkType(cursor.getString(idx_net_type)); network.setDate(simpleDateFormat.parse(cursor.getString(idx_date))); lista.add(network); } while (cursor.moveToNext()); } lista.remove(0); cursor.close(); closeDatabase(); return lista; }