List of usage examples for android.database Cursor getString
String getString(int columnIndex);
From source file:io.coldstart.android.Trap.java
public Trap(Cursor cursor) { //{ "trapID","trapHostName","trapIP","trapDate","trapUptime","trapPayload","trapRead" }; this.trapID = cursor.getInt(0); this.Hostname = cursor.getString(1); this.IP = cursor.getString(2); this.date = cursor.getString(3); this.uptime = cursor.getString(4); this.trap = cursor.getString(5); int read = cursor.getInt(6); if (read == 0) { this.read = false; } else {/*from w ww .j a v a2 s . c om*/ this.read = true; } try { this.trapCount = cursor.getInt(7); Log.e("TrapCount", Integer.toString(this.trapCount)); } catch (Exception e) { e.printStackTrace(); } }
From source file:foam.zizim.android.BoskoiService.java
public static List<BlogData> getBlogData() { Cursor cursor; cursor = BoskoiApplication.mDb.fetchAllBlog(); List blog = new ArrayList<BlogData>(); if (cursor.moveToFirst()) { int idIndex = cursor.getColumnIndexOrThrow(BoskoiDatabase.BLOG_ID); int titleIndex = cursor.getColumnIndexOrThrow(BoskoiDatabase.BLOG_TITLE); int dateIndex = cursor.getColumnIndexOrThrow(BoskoiDatabase.BLOG_DATE); int descIndex = cursor.getColumnIndexOrThrow(BoskoiDatabase.BLOG_DESCRIPTION); int linkIndex = cursor.getColumnIndexOrThrow(BoskoiDatabase.BLOG_LINK); do {// www .j a va2 s . com BlogData blogData = new BlogData(); blogData.setId(Util.toInt(cursor.getString(idIndex))); blogData.setTitle(cursor.getString(titleIndex)); blogData.setDescription(cursor.getString(descIndex)); blogData.setLink(cursor.getString(linkIndex)); blogData.setDate(cursor.getString(dateIndex)); blog.add(blogData); } while (cursor.moveToNext()); } cursor.close(); return blog; }
From source file:com.codebutler.farebot.transit.SuicaTransitData.java
/** * ?????/* w w w . java 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:io.coldstart.android.Trap.java
public Trap(Cursor cursor, boolean noCount) { //{ "trapID","trapHostName","trapIP","trapDate","trapUptime","trapPayload","trapRead" }; this.trapID = cursor.getInt(0); this.Hostname = cursor.getString(1); this.IP = cursor.getString(2); this.date = cursor.getString(3); this.uptime = cursor.getString(4); this.trap = cursor.getString(5); int read = cursor.getInt(6); if (read == 0) { this.read = false; } else {// w w w . j a v a 2s .c o m this.read = true; } }
From source file:ro.weednet.contactssync.platform.ContactManager.java
public static void updateContact(Context context, ContentResolver resolver, RawContact rawContact, boolean updateAvatar, boolean inSync, long rawContactId, BatchOperation batchOperation) { ContactsSync app = ContactsSync.getInstance(); boolean existingAvatar = false; final Cursor c = resolver.query(DataQuery.CONTENT_URI, DataQuery.PROJECTION, DataQuery.SELECTION, new String[] { String.valueOf(rawContactId) }, null); final ContactOperations contactOp = ContactOperations.updateExistingContact(context, rawContactId, inSync, batchOperation);/*from ww w. j a v a2 s .c o m*/ try { // Iterate over the existing rows of data, and update each one // with the information we received from the server. while (c.moveToNext()) { final long id = c.getLong(DataQuery.COLUMN_ID); final String mimeType = c.getString(DataQuery.COLUMN_MIMETYPE); final Uri uri = ContentUris.withAppendedId(Data.CONTENT_URI, id); if (mimeType.equals(StructuredName.CONTENT_ITEM_TYPE)) { contactOp.updateName(uri, c.getString(DataQuery.COLUMN_GIVEN_NAME), c.getString(DataQuery.COLUMN_FAMILY_NAME), rawContact.getFirstName(), rawContact.getLastName()); /* } else if (mimeType.equals(Phone.CONTENT_ITEM_TYPE)) { final int type = c.getInt(DataQuery.COLUMN_PHONE_TYPE); if (type == Phone.TYPE_MOBILE) { existingCellPhone = true; contactOp.updatePhone( c.getString(DataQuery.COLUMN_PHONE_NUMBER), "5345345", uri); } else if (type == Phone.TYPE_HOME) { existingHomePhone = true; contactOp.updatePhone( c.getString(DataQuery.COLUMN_PHONE_NUMBER), "5345345", uri); } else if (type == Phone.TYPE_WORK) { existingWorkPhone = true; contactOp.updatePhone( c.getString(DataQuery.COLUMN_PHONE_NUMBER), "5345345", uri); } */ } else if (mimeType.equals(Photo.CONTENT_ITEM_TYPE)) { existingAvatar = true; if (app.getSyncType() == ContactsSync.SyncType.LEGACY) { contactOp.updateAvatar(c.getString(DataQuery.COLUMN_DATA1), rawContact.getAvatarUrl(), uri); } } } // while } finally { c.close(); } // Add the avatar if we didn't update the existing avatar if (app.getSyncType() != ContactsSync.SyncType.HARD && !existingAvatar) { contactOp.addAvatar(rawContact.getAvatarUrl()); } // If we don't have a status profile, then create one. This could // happen for contacts that were created on the client - we don't // create the status profile until after the first sync... final String serverId = rawContact.getUid(); final long profileId = lookupProfile(resolver, serverId); if (profileId <= 0) { contactOp.addProfileAction(serverId); } }
From source file:com.energysystem.videoexplorerTV.video.VideoProvider.java
public static HashMap<String, List<Video>> buildMedia(String url, Cursor data) throws JSONException { mMovieList = new HashMap<String, List<Video>>(); mMovieList.clear();/*from ww w .j a v a2 s .c o m*/ Log.e("Abrimos", "Videos"); List<Video> categoryList = new ArrayList<Video>(); List<Video> categoryList2 = new ArrayList<Video>(); while (data.moveToNext()) { int videoID = data.getInt(data.getColumnIndex(MediaStore.Video.Media._ID)); int title = data.getColumnIndexOrThrow(MediaStore.Video.Media.TITLE); int category = data.getColumnIndexOrThrow(MediaStore.Video.Media.CATEGORY); int durationID = data.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION); int data_string = data.getColumnIndexOrThrow(MediaStore.Video.Media.DATA); //int videoUrl = data.getColumnIndexOrThrow(MediaStore.Video.Media.EXTERNAL_CONTENT_URI.toString()); // int bgImageUrl = data.getColumnIndexOrThrow(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI.toString()); int duration = Integer.parseInt(data.getString(durationID)); String categoria = new File(data.getString(data_string)).getParent(); Log.e("Ruta:", categoria); if (categoria.equals("/storage/emulated/0/Movies")) { categoryList.add(buildMovieInfo(categoria, data.getString(title), "Descripcion", String.format("%d min, %d sec", TimeUnit.MILLISECONDS.toMinutes(duration), TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration))), ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoID).toString(), ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoID).toString(), ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoID) .toString())); mMovieList.put("Almacenamiento Interno", categoryList); } else { categoryList2.add(buildMovieInfo(categoria, data.getString(title), "Descripcion", String.format("%d min, %d sec", TimeUnit.MILLISECONDS.toMinutes(duration), TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration))), ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoID).toString(), ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoID).toString(), ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoID) .toString())); mMovieList.put("USB", categoryList2); } } /*JSONObject jsonObj = new VideoProvider().parseUrl(url); JSONArray categories = jsonObj.getJSONArray(TAG_GOOGLE_VIDEOS); if (null != categories) { Log.d(TAG, "category #: " + categories.length()); String title; String videoUrl; String bgImageUrl; String cardImageUrl; String studio; for (int i = 0; i < categories.length(); i++) { JSONObject category = categories.getJSONObject(i); String category_name = category.getString(TAG_CATEGORY); JSONArray videos = category.getJSONArray(TAG_MEDIA); Log.d(TAG, "category: " + i + " Name:" + category_name + " video length: " + videos.length()); List<Video> categoryList = new ArrayList<Video>(); if (null != videos) { for (int j = 0; j < videos.length(); j++) { JSONObject video = videos.getJSONObject(j); String description = video.getString(TAG_DESCRIPTION); JSONArray videoUrls = video.getJSONArray(TAG_SOURCES); if (null == videoUrls || videoUrls.length() == 0) { continue; } title = video.getString(TAG_TITLE); videoUrl = getVideoPrefix(category_name, videoUrls.getString(0)); bgImageUrl = getThumbPrefix(category_name, title, video.getString(TAG_BACKGROUND)); cardImageUrl = getThumbPrefix(category_name, title, video.getString(TAG_CARD_THUMB)); studio = video.getString(TAG_STUDIO); categoryList.add(buildMovieInfo(category_name, title, description, studio, videoUrl, cardImageUrl, bgImageUrl)); } mMovieList.put(category_name, categoryList); } } }*/ Log.e("VideoProvider", "Tamano mMovie: " + mMovieList.size()); return mMovieList; }
From source file:android.database.DatabaseUtils.java
/** * Reads a String out of a column in a Cursor and writes it to a ContentValues. * Adds nothing to the ContentValues if the column isn't present or if its value is null. * * @param cursor The cursor to read from * @param column The column to read//from w w w . j a v a 2s.c om * @param values The {@link ContentValues} to put the value into */ public static void cursorStringToContentValuesIfPresent(Cursor cursor, ContentValues values, String column) { final int index = cursor.getColumnIndexOrThrow(column); if (!cursor.isNull(index)) { values.put(column, cursor.getString(index)); } }
From source file:com.markupartist.sthlmtraveling.PlannerFragment.java
private static JourneyQuery getJourneyQuery(Cursor cursor) { String jsonJourneyQuery;//from ww w . j ava 2 s.co m try { // TODO: Investigate if we can add some kind of caching here. jsonJourneyQuery = cursor.getString(COLUMN_INDEX_JOURNEY_DATA); } catch (Exception e) { Log.e(TAG, "Failed to retrieve journey data from the cursor."); return null; } JourneyQuery journeyQuery = null; try { journeyQuery = JourneyQuery.fromJson(new JSONObject(jsonJourneyQuery)); } catch (JSONException e) { Log.e(TAG, "Failed to covert to journey from json."); } return journeyQuery; }
From source file:com.phicomm.account.operator.GetMapOperation.java
@Override public Bundle execute(Context context, Request request) { String ssession_id = null;// w w w . j a v a2 s . c om Bundle resultData = new Bundle(); Cursor persionCursor = context.getContentResolver().query(Provider.PersonColumns.CONTENT_URI, null, null, null, null); if (persionCursor != null) { if (persionCursor.moveToFirst()) { ssession_id = persionCursor .getString(persionCursor.getColumnIndex(Provider.PersonColumns.JSSESSIONID)); } persionCursor.close(); } String url = WSConfig.WS_GET_MAP_URL + ssession_id; NetworkConnection networkConnection1 = new NetworkConnection(context, url); ArrayList<BasicNameValuePair> parameterList = new ArrayList<BasicNameValuePair>(); BasicNameValuePair value = new BasicNameValuePair("XML", ""); parameterList.add(value); networkConnection1.setParameters(parameterList); try { ConnectionResult result = networkConnection1.execute(); resultData.putString("result", result.body); Log.i("ss", "map________________________________result.body:" + result.body); } catch (ConnectionException e) { e.printStackTrace(); } Log.i("ss", "_______________________________________OK"); return resultData; }
From source file:cm.aptoide.com.facebook.android.Facebook.java
/** * Get Attribution ID for app install conversion tracking. * @param contentResolver//from www . 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; }