List of usage examples for android.database Cursor getColumnName
String getColumnName(int columnIndex);
From source file:com.mfcoding.locationBP.UI.fragments.LocationListFragment.java
/** * {@inheritDoc}//w w w .j a va2 s . c o m * When the loading has completed, assign the cursor to the adapter / list. */ public void onLoadFinished(Loader<Cursor> loader, Cursor data) { Log.d(TAG, "onLoadFinished # columns:" + data.getColumnCount()); for (int i = 0; i < data.getColumnCount(); i++) { Log.d(TAG, String.format("data.column[%d]=%s", i, data.getColumnName(i))); } adapter.swapCursor(data); }
From source file:de.escoand.readdaily.AbstractContentFragment.java
@Override public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) { View source = ((ViewGroup) view.getParent()).findViewById(R.id.daily_source); switch (cursor.getColumnName(columnIndex)) { // title/*from ww w . ja v a 2 s . c o m*/ case Database.COLUMN_TITLE: switch (cursor.getString(cursor.getColumnIndex(Database.COLUMN_TYPE))) { case Database.TYPE_YEAR: ((TextView) view).setText(getContext().getString(R.string.type_voty)); return true; case Database.TYPE_MONTH: ((TextView) view).setText(getContext().getString(R.string.type_votm)); return true; case Database.TYPE_WEEK: ((TextView) view).setText(getContext().getString(R.string.type_votw)); return true; case Database.TYPE_DAY: ((TextView) view).setText(getContext().getString(R.string.type_votd)); source.setVisibility(View.GONE); return true; default: // do nothing break; } break; // text case Database.COLUMN_TEXT: if (view instanceof TextView) { ((TextView) view).setText(Html.fromHtml(cursor.getString(columnIndex))); return true; } break; // source case Database.COLUMN_SOURCE: if (cursor.isNull(columnIndex)) { view.setVisibility(View.GONE); return true; } break; // do nothing default: break; } return false; }
From source file:piuk.blockchain.android.ui.ExchangeRatesFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); setEmptyText(getString(R.string.exchange_rates_fragment_empty_text)); adapter = new SimpleCursorAdapter(getActivity(), R.layout.exchange_rate_row, null, new String[] { ExchangeRatesProvider.KEY_CURRENCY_CODE, ExchangeRatesProvider.KEY_EXCHANGE_RATE_15M, ExchangeRatesProvider.KEY_EXCHANGE_RATE_24H, ExchangeRatesProvider.KEY_EXCHANGE_RATE_SYMBOL }, new int[] { R.id.exchange_rate_currency_code, R.id.exchange_rate_value, R.id.exchange_up_down, R.id.exchange_rate_symbol }, 0);//w w w.j a v a2s.co m adapter.setViewBinder(new ViewBinder() { public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) { String columnName = cursor.getColumnName(columnIndex); if (columnName.equals(ExchangeRatesProvider.KEY_CURRENCY_CODE)) { return false; } else if (columnName.equals(ExchangeRatesProvider.KEY_EXCHANGE_RATE_15M)) { final TextView valueView = (TextView) view; final double _15m = cursor.getDouble(columnIndex); valueView.setText(format.format(_15m)); return true; } else if (columnName.equals(ExchangeRatesProvider.KEY_EXCHANGE_RATE_15M)) { final TextView valueView = (TextView) view; final String symbol = cursor.getString(columnIndex); valueView.setText(symbol); return true; } else if (columnName.equals(ExchangeRatesProvider.KEY_EXCHANGE_RATE_24H)) { final ImageView image = (ImageView) view; double _15MValue = cursor .getDouble(cursor.getColumnIndex(ExchangeRatesProvider.KEY_EXCHANGE_RATE_15M)); double _24HValue = cursor.getDouble(columnIndex); if (_15MValue > _24HValue) { image.setImageResource(R.drawable.icon_up_green); } else if (_15MValue < _24HValue) { image.setImageResource(R.drawable.icon_down_red); } else { image.setImageResource(R.drawable.icon_right_black); } return true; } return false; } }); setListAdapter(adapter); getLoaderManager().initLoader(0, null, this); }
From source file:com.feathercoin.wallet.feathercoin.ui.SendingAddressesFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setEmptyText(getString(R.string.address_book_empty_text)); adapter = new SimpleCursorAdapter(activity, R.layout.address_book_row, null, new String[] { AddressBookProvider.KEY_LABEL, AddressBookProvider.KEY_ADDRESS }, new int[] { R.id.address_book_row_label, R.id.address_book_row_address }, 0); adapter.setViewBinder(new ViewBinder() { public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) { if (!AddressBookProvider.KEY_ADDRESS.equals(cursor.getColumnName(columnIndex))) return false; ((TextView) view).setText(WalletUtils.formatHash(cursor.getString(columnIndex), Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); return true; }/*from ww w.ja v a2 s.c o m*/ }); setListAdapter(adapter); loaderManager.initLoader(0, null, this); }
From source file:com.guldencoin.androidwallet.nlg.ui.SendingAddressesFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setEmptyText(getString(R.string.address_book_empty_text)); adapter = new SimpleCursorAdapter(activity, R.layout.address_book_row, null, new String[] { AddressBookProvider.KEY_LABEL, AddressBookProvider.KEY_ADDRESS }, new int[] { R.id.address_book_row_label, R.id.address_book_row_address }, 0); adapter.setViewBinder(new ViewBinder() { @Override/* www . j ava 2s . co m*/ public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) { if (!AddressBookProvider.KEY_ADDRESS.equals(cursor.getColumnName(columnIndex))) return false; ((TextView) view).setText(WalletUtils.formatHash(cursor.getString(columnIndex), Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); return true; } }); setListAdapter(adapter); loaderManager.initLoader(0, null, this); }
From source file:cc.mintcoin.wallet.ui.SendingAddressesFragment.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);/*w w w . j a v a 2 s . c o m*/ adapter = new SimpleCursorAdapter(activity, R.layout.address_book_row, null, new String[] { AddressBookProvider.KEY_LABEL, AddressBookProvider.KEY_ADDRESS }, new int[] { R.id.address_book_row_label, R.id.address_book_row_address }, 0); adapter.setViewBinder(new ViewBinder() { @Override public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) { if (!AddressBookProvider.KEY_ADDRESS.equals(cursor.getColumnName(columnIndex))) return false; ((TextView) view).setText(WalletUtils.formatHash(cursor.getString(columnIndex), Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE)); return true; } }); setListAdapter(adapter); loaderManager.initLoader(0, null, this); }
From source file:zw.co.noityu.notifyu.activities.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); DbHelper mDbHelper = new DbHelper(getApplicationContext()); SQLiteDatabase db = mDbHelper.getWritableDatabase(); DbTask dbTask = new DbTask(getApplicationContext(), db); Cursor c = dbTask.readAllUsers(); if (!c.moveToFirst()) { Log.d("##################################", c.getColumnName(1)); Intent intent = new Intent(getBaseContext(), SetupActivity.class); startActivity(intent);// ww w. j a va2s . c o m } String url = "www.notifyu.co/getSchools"; String message = "Fetching Schools..."; JSONObject arguments = new JSONObject(); WebServiceAdapter webServiceAdapter = new WebServiceAdapter(); //webServiceAdapter.call(url, message, arguments, context); mDisplay = (TextView) findViewById(R.id.display); context = getApplicationContext(); // Check device for Play Services APK. If check succeeds, proceed with GCM registration. if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(context); if (regid.isEmpty()) { registerInBackground(); } } else { Log.i(TAG, "No valid Google Play Services APK found."); } }
From source file:com.popumovies.DetailActivityFragment.java
private void updateMovieDetails(Cursor cursor) { if (cursor.moveToFirst()) { Bundle args = new Bundle(); for (int i = 0; i < cursor.getColumnCount(); ++i) { args.putString(cursor.getColumnName(i), cursor.getString(i)); }// ww w . jav a2 s . c o m fillForm(args); } }
From source file:org.egov.android.data.SQLiteHelper.java
public JSONArray query(String sql) { JSONArray data = new JSONArray(); JSONObject row = null;/*from w ww . j a v a 2 s.co m*/ Cursor cursor = query(sql, null); cursor.moveToFirst(); while (!cursor.isAfterLast()) { row = new JSONObject(); int cc = cursor.getColumnCount(); for (int i = 0; i < cc; i++) { try { row.put(cursor.getColumnName(i), cursor.getString(i)); } catch (JSONException e) { e.printStackTrace(); } } data.put(row); cursor.moveToNext(); } cursor.close(); return data.length() == 0 ? null : data; }
From source file:edu.asu.bscs.csiebler.waypointdatabase.MainActivity.java
private JSONArray getJsonResults() { JSONArray resultSet = new JSONArray(); try {//from w w w . j a va 2s .co m WaypointDB db = new WaypointDB(this); db.copyDB(); SQLiteDatabase waypointDB = db.openDB(); waypointDB.beginTransaction(); String searchQuery = "SELECT * FROM waypoint"; Cursor cursor = waypointDB.rawQuery(searchQuery, null); cursor.moveToFirst(); while (cursor.isAfterLast() == false) { int totalColumn = cursor.getColumnCount(); JSONObject rowObject = new JSONObject(); for (int i = 0; i < totalColumn; i++) { if (cursor.getColumnName(i) != null) { try { if (cursor.getString(i) != null) { Log.d("TAG_NAME", cursor.getString(i)); rowObject.put(cursor.getColumnName(i), cursor.getString(i)); } else { rowObject.put(cursor.getColumnName(i), ""); } } catch (Exception e) { Log.d("TAG_NAME", e.getMessage()); } } } resultSet.put(rowObject); cursor.moveToNext(); } cursor.close(); waypointDB.endTransaction(); waypointDB.close(); db.close(); Log.d("TAG_NAME", resultSet.toString()); } catch (Exception ex) { Log.w(getClass().getSimpleName(), "Exception creating adapter: " + ex.getMessage()); } return resultSet; }