以下是我正在使用的代码段:
...
final String[] PROJECTION = new String[] {
People._ID, People.NAME
};
preparePeople();
final Cursor c = mContext.getContentResolver().query(People.CONTENT_URI, PROJECTION, null, null, null);
android.util.Log.i("TAG","Rowcount =" + **c.getCount()**);
c.moveToFirst();
String s = **c.getString(0)**;
...
private void preparePeople() {
final ContentResolver mResolver = mContext.getContentResolver();
mResolver.delete(People.CONTENT_URI, null, null);
final ContentValues valuse = new ContentValues();
valuse.put(People._ID, "1");
valuse.put(People.NAME, "name");
Uri uri = mResolver.insert(People.CONTENT_URI, valuse);
}
...
这里的问题是它在日志中返回 Rowcount = 0 并给出以下异常:
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
请帮我解决这个问题,为什么它没有显示行?