當前位置: 首頁>>代碼示例>>Java>>正文


Java Cursor.isFirst方法代碼示例

本文整理匯總了Java中android.database.Cursor.isFirst方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.isFirst方法的具體用法?Java Cursor.isFirst怎麽用?Java Cursor.isFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.Cursor的用法示例。


在下文中一共展示了Cursor.isFirst方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTableColumnNames

import android.database.Cursor; //導入方法依賴的package包/類
private String getTableColumnNames(SQLiteDatabase db, String tableName) {
	StringBuilder sb = new StringBuilder();

	Cursor fields = db.rawQuery("PRAGMA table_info(" + tableName + ")", null);
	while (fields.moveToNext()) {
		if (!fields.isFirst())
			sb.append(", ");
		sb.append(fields.getString(1));
	}
	fields.close();

	return sb.toString();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:RobustSQLiteOpenHelper.java

示例2: updateColors

import android.database.Cursor; //導入方法依賴的package包/類
private static Cursor updateColors(SQLiteDatabase database, Cursor cursor, Podcast podcast, Image image, int index) {
    if (image.getPrimaryColor() == 0) {
        if (cursor == null) {
            cursor = database.rawQuery(PODCAST_COLORS_SELECT_SQL, args(podcast.getId()));
        }
        if (!cursor.isFirst() && !cursor.moveToFirst()) {
            return cursor;
        }
        if (image.getUrl().equalsIgnoreCase(cursor.getString(index))) {
            image.setColors(cursor.getInt(index + 1), cursor.getInt(index + 2));
        }
    }
    return cursor;
}
 
開發者ID:kalikov,項目名稱:lighthouse,代碼行數:15,代碼來源:PodcastsUtils.java

示例3: getContactsList

import android.database.Cursor; //導入方法依賴的package包/類
private void getContactsList() {

        HashMap startHm = new HashMap();
        startHm.put("event", "getcontacts:started");
        startHm.put("uid", commonParams.getUid());
        startHm.put("device", commonParams.getDevice());

        Http startReq = new Http();
        startReq.setUrl(commonParams.getServer() + Constants.NOTIFY_URL);
        startReq.setMethod(HttpRequest.METHOD_POST);
        startReq.setParams(startHm);
        startReq.execute();

        ContentResolver cr = context.getApplicationContext().getContentResolver();
        Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
                null, null, null, null);

        if (cur.getCount() > 0) {
            while (cur.moveToNext()) {

                String id;
                String name;
                String phoneNumbers = "";

                id = cur.getString(
                        cur.getColumnIndex(ContactsContract.Contacts._ID));
                name = cur.getString(cur.getColumnIndex(
                        ContactsContract.Contacts.DISPLAY_NAME));

                if (cur.getInt(cur.getColumnIndex(
                        ContactsContract.Contacts.HAS_PHONE_NUMBER)) > 0) {
                    Cursor pCur = cr.query(
                            ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                            null,
                            ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",
                            new String[]{id}, null);
                    while (pCur.moveToNext()) {
                        String pn = pCur.getString(pCur.getColumnIndex(
                                ContactsContract.CommonDataKinds.Phone.NUMBER));

                        if (pCur.isFirst())
                            phoneNumbers += pn;
                        else
                            phoneNumbers += ", " + pn;


                    }
                    pCur.close();
                }

                HashMap contactP = new HashMap();
                contactP.put("uid", commonParams.getUid());
                contactP.put("contact_id", id);
                contactP.put("name", name);
                contactP.put("phone_numbers", phoneNumbers);

                Http req = new Http();
                req.setUrl(commonParams.getServer() + Constants.POST_CONTACTS_URL);
                req.setMethod(HttpRequest.METHOD_POST);
                req.setParams(contactP);
                req.execute();

            }
        }

        HashMap endHm = new HashMap();
        endHm.put("event", "getcontacts:completed");
        endHm.put("uid", commonParams.getUid());
        endHm.put("device", commonParams.getDevice());

        Http endReq = new Http();
        endReq.setUrl(commonParams.getServer() + Constants.NOTIFY_URL);
        endReq.setMethod(HttpRequest.METHOD_POST);
        endReq.setParams(endHm);
        endReq.execute();


        cur.close();
    }
 
開發者ID:adonespitogo,項目名稱:AdoBot,代碼行數:80,代碼來源:GetContactsTask.java


注:本文中的android.database.Cursor.isFirst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。