今用的时候偶然发现,我以前认为它是先从rowid=1开始遍历的,然而不是,是从最后,rowid=最后 开始,然后向上逐级遍历,最后才是遍历rowid=1。
我现在还在纳闷儿为什么,然而事实就是如此。
<script type="text/javascript">
$(function () {
$('pre.prettyprint code').each(function () {
var lines = $(this).text().split('\n').length;
var $numbering = $('<ul/>').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i <= lines; i++) {
$numbering.append($('<li/>').text(i));
};
$numbering.fadeIn(1700);
});
});
</script>
分享到:
相关推荐
while (cursor.moveToNext()) { String displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String phoneNumber = cursor.getString(cursor....
while (cursor.moveToNext()) { String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); String name = cursor.getString(cursor.getColumnIndex(ContactsContract....
while (cursor.moveToNext()) { String title = cursor.getString(cursor.getColumnIndex(CalendarContract.Events.TITLE)); String description = cursor.getString(cursor.getColumnIndex(CalendarContract....
} while (cursor.moveToNext()); } cursor.close(); ``` 在这个示例中,我们首先获取了联系人的ID(`_ID`),然后通过这个ID查询电话号码。对于中间名(middlename),我们需要再次查询`ContactsContract.Data....
cursor.moveToNext()) { String name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); char firstChar = Character.toUpperCase(name.charAt(0)); if (!...
} while (cursor.moveToNext()); return list; } ``` 这段代码实现了通过`ContentResolver`查询通话记录的功能,并将结果存储在一个`ArrayList, String>>`中,每个`HashMap`包含了一个通话记录的详细信息(如...
while (cursor.moveToNext()) { String name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String phoneNumber = cursor.getString(cursor.getColumnIndex...
} while (cursor.moveToNext()); } cursor.close(); ``` 以上代码会遍历所有联系人,获取他们的显示名称和电话号码。记得关闭Cursor以释放资源。 除了从设备内部存储获取联系人,我们还可以访问SIM卡中的联系人。...
while (cursor.moveToNext()) { String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts....
} while (cursor.moveToNext()); } ``` 4. **拨打电话**:使用`Intent`启动电话拨号器: ```java private void callPhoneNumber(String phoneNumber) { Intent intent = new Intent(Intent.ACTION_DIAL); intent....
} while (cursor.moveToNext()); } cursor.close(); ``` 在这个例子中,我们查询了所有电话号码,获取了每个联系人的显示名称和电话号码。`CONTENT_URI`是ContactsContract类中的常量,代表所有联系人的内容提供...
} while (cursor.moveToNext()); } ``` 此外,为了实现高效的播放功能,音乐播放器通常还需要使用`MediaPlayer`类,这是一个强大的音频和视频播放引擎。开发者可以利用`MediaPlayer`的API来控制播放、暂停、停止、...
while (cursor.moveToNext()) { String name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String number = cursor.getString(cursor.getColumnIndex...
while (cursor.moveToNext()) { String name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String number = cursor.getString(cursor.getColumnIndex...
= null && cursor.moveToNext()) { String name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String phoneNumber = cursor.getString(cursor....
while (cursor.moveToNext()) { String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); // 进一步处理每个联系人的ID } cursor.close(); ``` 获取到联系人ID后,我们可以...
} while (cursor.moveToNext()); } cursor.close(); ``` 如果我们要同时获取SIM卡上的联系人,可以使用`ContactsContract.PhoneLookup`类的URI,并指定`Phone.TYPE`为`Phone.TYPE_SIM`: ```java Uri ...
} while (cursor.moveToNext()); } cursor.close(); ``` ContentProvider不仅限于SQLite数据库,还可以用于读取文件、网络数据等。通过实现ContentProvider,你可以将任何数据源包装成标准的Android接口,使得其他...
} while (cursor.moveToNext()); } cursor.close(); // 记得关闭Cursor,避免资源泄漏 ``` 5. **获取最新短信**: 若要获取最新的一条短信,可以在查询时指定排序方式,例如按时间降序排列: ```java Cursor...
while (cursor.moveToNext()) { String name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String number = cursor.getString(cursor.getColumnIndex...