List of usage examples for android.database Cursor getInt
int getInt(int columnIndex);
From source file:com.mp3tunes.android.player.content.LockerDb.java
private Track cursorToTrack(Cursor c) { if (c == null) return null; try {//from w w w.jav a 2s . co m if (c.moveToFirst()) { int id = c.getInt(Music.TRACK_MAPPING.ID); int artist_id = c.getInt(Music.TRACK_MAPPING.ARTIST_ID); int album_id = c.getInt(Music.TRACK_MAPPING.ALBUM_ID); String play_url = c.getString(Music.TRACK_MAPPING.PLAY_URL); String title = c.getString(Music.TRACK_MAPPING.TITLE); String artist_name = c.getString(Music.TRACK_MAPPING.ARTIST_NAME); String album_name = c.getString(Music.TRACK_MAPPING.ALBUM_NAME); Track t = new ConcreteTrack(new LockerId(id), play_url, title, artist_id, artist_name, album_id, album_name); return t; } } finally { c.close(); } return null; }
From source file:cn.loveapple.client.android.database.impl.TemperatureDaoImpl.java
/** * // ww w . ja v a2s . c o m * @param cursor * @return */ private TemperatureEntity getTemperatureEntity(Cursor cursor) { if (cursor.getCount() < 1) { return null; } TemperatureEntity result = new TemperatureEntity(); result.setDate(cursor.getString(0)); result.setTimestamp(cursor.getString(1)); result.setTemperature(cursor.getDouble(2)); result.setCoitusFlg(cursor.getString(3)); result.setMenstruationFlg(cursor.getString(4)); result.setDysmenorrheaFlg(cursor.getString(5)); result.setLeukorrhea(cursor.getString(6)); result.setMenstruationLevel(cursor.getString(7)); result.setMenstruationCycle(cursor.getInt(8)); return result; }
From source file:com.dwdesign.tweetings.fragment.AccountsFragment.java
@Override public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) { mCursor = data;/* ww w . j ava 2s .com*/ mAdapter.swapCursor(data); final SparseBooleanArray checked = new SparseBooleanArray(); data.moveToFirst(); //if (mSelectedIds.size() == 0) { while (!data.isAfterLast()) { final boolean is_activated = data.getInt(data.getColumnIndexOrThrow(Accounts.IS_ACTIVATED)) == 1; final long user_id = data.getLong(data.getColumnIndexOrThrow(Accounts.USER_ID)); //if (is_activated) { //mSelectedIds.add(user_id); //} //View v = (View) getListView().getItemAtPosition(data.getPosition()); //CheckBox cb = (CheckBox) v.findViewById(R.id.checkbox); //cb.setChecked(is_activated); //mAdapter.setItemChecked(data.getPosition(), is_activated); data.moveToNext(); } /*} else { while (!cursor.isAfterLast()) { final long user_id = cursor.getLong(cursor.getColumnIndexOrThrow(Accounts.ACCOUNT_ID)); if (mSelectedIds.contains(user_id)) { checked.put(cursor.getPosition(), true); mAdapter.setItemChecked(cursor.getPosition(), true); } cursor.moveToNext(); } }*/ }
From source file:com.chen.mail.providers.Attachment.java
public Attachment(Cursor cursor) { if (cursor == null) { return;/*ww w . j a va 2 s .com*/ } name = cursor.getString(cursor.getColumnIndex(UIProvider.AttachmentColumns.NAME)); size = cursor.getInt(cursor.getColumnIndex(UIProvider.AttachmentColumns.SIZE)); uri = Uri.parse(cursor.getString(cursor.getColumnIndex(UIProvider.AttachmentColumns.URI))); contentType = cursor.getString(cursor.getColumnIndex(UIProvider.AttachmentColumns.CONTENT_TYPE)); state = cursor.getInt(cursor.getColumnIndex(UIProvider.AttachmentColumns.STATE)); destination = cursor.getInt(cursor.getColumnIndex(UIProvider.AttachmentColumns.DESTINATION)); downloadedSize = cursor.getInt(cursor.getColumnIndex(UIProvider.AttachmentColumns.DOWNLOADED_SIZE)); contentUri = parseOptionalUri( cursor.getString(cursor.getColumnIndex(UIProvider.AttachmentColumns.CONTENT_URI))); thumbnailUri = parseOptionalUri( cursor.getString(cursor.getColumnIndex(UIProvider.AttachmentColumns.THUMBNAIL_URI))); previewIntentUri = parseOptionalUri( cursor.getString(cursor.getColumnIndex(UIProvider.AttachmentColumns.PREVIEW_INTENT_URI))); providerData = cursor.getString(cursor.getColumnIndex(UIProvider.AttachmentColumns.PROVIDER_DATA)); supportsDownloadAgain = cursor .getInt(cursor.getColumnIndex(UIProvider.AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN)) == 1; type = cursor.getInt(cursor.getColumnIndex(UIProvider.AttachmentColumns.TYPE)); flags = cursor.getInt(cursor.getColumnIndex(UIProvider.AttachmentColumns.FLAGS)); }
From source file:com.mp3tunes.android.player.content.LockerDb.java
private Artist cursorToArtist(Cursor c) { if (c == null) return null; try {/*from w w w .j a va 2 s . c om*/ if (c.moveToFirst()) { Artist a = new Artist(new LockerId(c.getInt(Music.ARTIST_MAPPING.ID)), c.getString(Music.ARTIST_MAPPING.ARTIST_NAME)); c.close(); return a; } } finally { c.close(); } return null; }
From source file:com.android.mail.providers.Attachment.java
public Attachment(Cursor cursor) { if (cursor == null) { return;//from ww w . j a v a2 s . c o m } name = cursor.getString(cursor.getColumnIndex(AttachmentColumns.NAME)); size = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.SIZE)); uri = Uri.parse(cursor.getString(cursor.getColumnIndex(AttachmentColumns.URI))); contentType = cursor.getString(cursor.getColumnIndex(AttachmentColumns.CONTENT_TYPE)); state = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.STATE)); destination = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.DESTINATION)); downloadedSize = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.DOWNLOADED_SIZE)); contentUri = parseOptionalUri(cursor.getString(cursor.getColumnIndex(AttachmentColumns.CONTENT_URI))); thumbnailUri = parseOptionalUri(cursor.getString(cursor.getColumnIndex(AttachmentColumns.THUMBNAIL_URI))); previewIntentUri = parseOptionalUri( cursor.getString(cursor.getColumnIndex(AttachmentColumns.PREVIEW_INTENT_URI))); providerData = cursor.getString(cursor.getColumnIndex(AttachmentColumns.PROVIDER_DATA)); supportsDownloadAgain = cursor .getInt(cursor.getColumnIndex(AttachmentColumns.SUPPORTS_DOWNLOAD_AGAIN)) == 1; type = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.TYPE)); flags = cursor.getInt(cursor.getColumnIndex(AttachmentColumns.FLAGS)); }
From source file:org.noorganization.instalistsynch.controller.synch.impl.TagSynch.java
@Override public void indexLocal(int _groupId, Date _lastIndexTime) { String lastIndexTime = ISO8601Utils.format(_lastIndexTime, false, TimeZone.getTimeZone("GMT+0000"));//.concat("+0000"); boolean isLocal = false; GroupAuth groupAuth = mGroupAuthDbController.getLocalGroup(); if (groupAuth != null) { isLocal = groupAuth.getGroupId() == _groupId; }/*from ww w. j av a 2 s.c o m*/ Cursor tagLogCursor = mClientLogDbController.getLogsSince(lastIndexTime, mModelType); if (tagLogCursor.getCount() == 0) { tagLogCursor.close(); return; } try { while (tagLogCursor.moveToNext()) { // fetch the action type int actionId = tagLogCursor.getInt(tagLogCursor.getColumnIndex(LogInfo.COLUMN.ACTION)); eActionType actionType = eActionType.getTypeById(actionId); List<ModelMapping> modelMappingList = mTagModelMappingController.get( ModelMapping.COLUMN.GROUP_ID + " = ? AND " + ModelMapping.COLUMN.CLIENT_SIDE_UUID + " LIKE ?", new String[] { String.valueOf(_groupId), tagLogCursor.getString(tagLogCursor.getColumnIndex(LogInfo.COLUMN.ITEM_UUID)) }); ModelMapping modelMapping = modelMappingList.size() == 0 ? null : modelMappingList.get(0); switch (actionType) { case INSERT: // skip insertion because this should be decided by the user if the non local groups should have access to the category // and also skip if a mapping for this case already exists! if (!isLocal || modelMapping != null) { continue; } String clientUuid = tagLogCursor .getString(tagLogCursor.getColumnIndex(LogInfo.COLUMN.ITEM_UUID)); Date clientDate = ISO8601Utils.parse( tagLogCursor.getString(tagLogCursor.getColumnIndex(LogInfo.COLUMN.ACTION_DATE)), new ParsePosition(0)); modelMapping = new ModelMapping(null, groupAuth.getGroupId(), null, clientUuid, new Date(Constants.INITIAL_DATE), clientDate, false); mTagModelMappingController.insert(modelMapping); break; case UPDATE: if (modelMapping == null) { Log.i(TAG, "indexLocal: the model is null but shouldn't be"); continue; } String timeString = tagLogCursor .getString(tagLogCursor.getColumnIndex(LogInfo.COLUMN.ACTION_DATE)); clientDate = ISO8601Utils.parse(timeString, new ParsePosition(0)); modelMapping.setLastClientChange(clientDate); mTagModelMappingController.update(modelMapping); break; case DELETE: if (modelMapping == null) { Log.i(TAG, "indexLocal: the model is null but shouldn't be"); continue; } modelMapping.setDeleted(true); timeString = tagLogCursor.getString(tagLogCursor.getColumnIndex(LogInfo.COLUMN.ACTION_DATE)); clientDate = ISO8601Utils.parse(timeString, new ParsePosition(0)); modelMapping.setLastClientChange(clientDate); mTagModelMappingController.update(modelMapping); break; default: } } } catch (Exception e) { tagLogCursor.close(); } }
From source file:com.cryart.sabbathschool.util.SSCore.java
public SSDay ssGetDay(String day_date) { SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT ss_days.*, ss_lessons.lesson_image as lesson_image " + "FROM ss_days, ss_lessons, ss_quarters " + "WHERE ss_days.day_date = ? AND ss_days.day_lesson_serial = ss_lessons.serial " + " AND ss_lessons.lesson_quarter_serial = ss_quarters.serial " + " AND ss_quarters.quarter_lang = ? LIMIT 1", new String[] { day_date, LANGUAGE }); if (cursor != null) cursor.moveToFirst();// ww w . j a v a2s. c om return new SSDay(cursor.getInt(0), cursor.getInt(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9)); }
From source file:com.concentricsky.android.khanacademy.data.KADataService.java
private void updateDownloadStatus(Intent intent, final PendingIntent pendingIntent, final int startId) { final long id = intent.getLongExtra(EXTRA_ID, -1); final DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); final DownloadManager.Query q = new DownloadManager.Query(); q.setFilterById(id);//from ww w . j ava 2s . c om new AsyncTask<Void, Void, Boolean>() { @Override protected Boolean doInBackground(Void... arg) { Cursor cursor = mgr.query(q); String youtubeId = null; int status = -1; if (cursor.moveToFirst()) { String filename = cursor .getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME)); youtubeId = OfflineVideoManager.youtubeIdFromFilename(filename); status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)); } cursor.close(); if (status == DownloadManager.STATUS_SUCCESSFUL && youtubeId != null) { try { Dao<Video, String> videoDao = helper.getVideoDao(); UpdateBuilder<Video, String> q = videoDao.updateBuilder(); q.where().eq("youtube_id", youtubeId); q.updateColumnValue("download_status", Video.DL_STATUS_COMPLETE); q.update(); return true; } catch (SQLException e) { e.printStackTrace(); } } return false; } @Override protected void onPostExecute(Boolean successful) { if (successful) { broadcastOfflineVideoSetChanged(); finish(startId, pendingIntent, RESULT_SUCCESS); } else { finish(startId, pendingIntent, RESULT_ERROR); } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:fr.unix_experience.owncloud_sms.engine.SmsFetcher.java
public JSONArray getLastMessage(MailboxID mbID) { String mbURI = mapMailboxIDToURI(mbID); if (_context == null || mbURI == null) { return null; }// w w w . java 2 s.c o m // Fetch Sent SMS Message from Built-in Content Provider Cursor c = (new SmsDataProvider(_context)).query(mbURI); c.moveToNext(); // We create a list of strings to store results JSONArray results = new JSONArray(); JSONObject entry = new JSONObject(); try { for (int idx = 0; idx < c.getColumnCount(); idx++) { String colName = c.getColumnName(idx); // Id column is must be an integer if (colName.equals(new String("_id")) || colName.equals(new String("type"))) { entry.put(colName, c.getInt(idx)); // bufferize Id for future use if (colName.equals(new String("_id"))) { } } // Seen and read must be pseudo boolean else if (colName.equals(new String("read")) || colName.equals(new String("seen"))) { entry.put(colName, c.getInt(idx) > 0 ? "true" : "false"); } else { entry.put(colName, c.getString(idx)); } } // Mailbox ID is required by server entry.put("mbox", mbID.ordinal()); results.put(entry); } catch (JSONException e) { Log.e(TAG, "JSON Exception when reading SMS Mailbox", e); c.close(); } c.close(); return results; }