List of usage examples for android.database Cursor moveToFirst
boolean moveToFirst();
From source file:com.pdftron.pdf.utils.Utils.java
public static String getUriColumnInfo(Context context, Uri contentUri, String column) { Cursor cursor = null; try {/*from w w w . j a va 2s. co m*/ String[] proj = { column }; cursor = context.getContentResolver().query(contentUri, proj, // Which columns to return null, // WHERE clause; which rows to return (all rows) null, // WHERE clause selection arguments (none) null); // Order-by clause (ascending by name) if (null != cursor) { cursor.moveToFirst(); int column_index = cursor.getColumnIndexOrThrow(proj[0]); return cursor.getString(column_index); } return ""; } catch (Exception e) { AnalyticsHandlerAdapter.getInstance().sendException(e); } finally { if (cursor != null) { cursor.close(); } } return ""; }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static Hashtable<String, Object> getHeaderRecordCatchedData(String group, long serverMsgNum, Context context) {/*from w w w .ja v a 2 s .c om*/ int groupid = getGroupIdFromName(group, context); Hashtable<String, Object> result = null; DBHelper db = new DBHelper(context); SQLiteDatabase dbread = db.getReadableDatabase(); Cursor c = dbread.rawQuery("SELECT _id, server_article_id, catched FROM headers WHERE subscribed_group_id=" + groupid + " AND server_article_number=" + serverMsgNum, null); if (c.getCount() == 1) { c.moveToFirst(); result = new Hashtable<String, Object>(3); result.put("id", c.getInt(0)); result.put("server_article_id", c.getString(1)); if (c.getInt(2) == 1) result.put("catched", true); else result.put("catched", false); } c.close(); dbread.close(); db.close(); return result; }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static Vector<Long> getPendingOutgoingMessageIds(Context context) { Vector<Long> retVal = null; DBHelper db = new DBHelper(context); SQLiteDatabase dbread = db.getReadableDatabase(); Cursor c = dbread.rawQuery("SELECT _id FROM offline_sent_posts", null); int count = c.getCount(); if (count == 0) { retVal = new Vector<Long>(0); } else {//from w w w .j a v a 2s . co m retVal = new Vector<Long>(count); c.moveToFirst(); for (int i = 0; i < count; i++) { retVal.add(c.getLong(0)); c.moveToNext(); } } c.close(); dbread.close(); db.close(); return retVal; }
From source file:cm.aptoide.com.facebook.android.Facebook.java
/** * Get Attribution ID for app install conversion tracking. * @param contentResolver/*from w ww. jav 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:net.peterkuterna.android.apps.devoxxfrsched.service.TwitterSearchService.java
@Override protected void doSync(Intent intent) throws Exception { Log.d(TAG, "Refreshing twitter results"); final Cursor c = mResolver.query(Tweets.CONTENT_URI, TweetsQuery.PROJECTION, null, null, null); String tweetId = "0"; try {/*from w ww . j av a2 s. c om*/ if (c.moveToFirst()) { tweetId = c.getString(TweetsQuery.MAX_TWEET_ID); } } finally { c.close(); } final Uri uri = TwitterApiUriUtils.buildTwitterSearchUri("#devoxxfr +exclude:retweets", tweetId); mRemoteExecutor.executeGet(uri.toString(), new TwitterSearchHandler()); }
From source file:net.peterkuterna.android.apps.devoxxsched.service.TwitterSearchService.java
@Override protected void doSync(Intent intent) throws Exception { Log.d(TAG, "Refreshing twitter results"); final Cursor c = mResolver.query(Tweets.CONTENT_URI, TweetsQuery.PROJECTION, null, null, null); String tweetId = "0"; try {/*from ww w .ja va2s.c o m*/ if (c.moveToFirst()) { tweetId = c.getString(TweetsQuery.MAX_TWEET_ID); } } finally { c.close(); } final Uri uri = TwitterApiUriUtils.buildTwitterSearchUri("from:Devoxx OR #devoxx +exclude:retweets", tweetId); mRemoteExecutor.executeGet(uri.toString(), new TwitterSearchHandler()); }
From source file:net.peterkuterna.android.apps.devoxxfrsched.service.NewsSyncService.java
@Override protected void doSync(Intent intent) throws Exception { Log.d(TAG, "Refreshing DevoxxFr twitter results"); boolean noNotifications = intent.getBooleanExtra(EXTRA_NO_NOTIFICATIONS, false); final Cursor c = mResolver.query(News.CONTENT_URI, NewsQuery.PROJECTION, null, null, null); String newsId = "0"; try {// w w w . j av a2 s .c om if (c.moveToFirst()) { newsId = c.getString(NewsQuery.MAX_NEWS_ID); } } finally { c.close(); } final Uri uri = TwitterApiUriUtils.buildTwitterSearchUri("from:DevoxxFr +exclude:retweets", newsId); mRemoteExecutor.executeGet(uri.toString(), new NewsHandler(noNotifications)); final NotifierManager notifierManager = new NotifierManager(this); notifierManager.notifyNewNewsItems(); Log.d(TAG, "News sync finished"); }
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 va 2 s . c o m 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:net.eledge.android.toolkit.db.internal.TableBuilder.java
private List<String> getExistingFields(Class<?> clazz) { List<String> names = new ArrayList<>(); StringBuilder sb = new StringBuilder("pragma table_info("); sb.append(SQLBuilder.getTableName(clazz)); sb.append(");"); Cursor cursor = db.rawQuery(sb.toString(), new String[] {}); if ((cursor != null) && cursor.moveToFirst()) { do {/*ww w . j a va 2s.com*/ names.add(cursor.getString(1)); } while (cursor.moveToNext()); cursor.close(); } return names; }
From source file:com.odoo.addons.notes.models.NoteNote.java
public int tagCount(int tag_id) { NoteTag tags = new NoteTag(mContext, getUser()); String rel_table = getTableName() + "_" + tags.getTableName() + "_rel as rel "; StringBuffer query = new StringBuffer(); query.append("SELECT count(id) FROM "); query.append(getTableName() + " as notes "); query.append("LEFT JOIN " + rel_table); query.append("ON rel.note_note_id = notes." + OColumn.ROW_ID); query.append(" WHERE rel.note_tag_id = " + tag_id); query.append(" and notes._is_active = 'true' and trashed = '0'"); Cursor cr = executeQuery(query.toString(), null); if (cr.moveToFirst()) { return cr.getInt(0); }//from ww w . j a v a2s .com return 0; }