小编use*_*945的帖子

限制ContentResolver.query()函数中的行数

有没有办法将返回的行数限制为游标?我有一个有大约4000个联系人的电话,我只需要其中一些.

这是我正在使用的代码

        db = new dBHelper(this);
        ContentResolver cr = getContentResolver();
        Cursor cursor;

        cursor = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, ContactName + " ASC");
        Log.i(TAG, CLASSNAME + " got contacts entries");
        for (int it = 0; it <100 ; it++){//cursor.getCount()
            Log.i(TAG, CLASSNAME + " getting string");
            String mytimes_contacted = cursor.getString(cursor.getColumnIndex(dBHelper.times_contacted)); 
            Log.i(TAG, CLASSNAME + " done from the string");
        }
Run Code Online (Sandbox Code Playgroud)

我得到的日志是

I/Check(11506): [ContactsPicker] got contacts entries
I/Check(11506): [ContactsPicker] getting first string
D/AndroidRuntime(11506): Shutting down VM
W/dalvikvm(11506): threadid=1: thread exiting with uncaught exception (group=0x2aac8578)
D/dalvikvm(11541): …
Run Code Online (Sandbox Code Playgroud)

database android contacts

31
推荐指数
3
解决办法
1万
查看次数

在c ++中签名short to byte

我正在尝试使用C++将十六进制数转换为一个短(2字节)一切都没问题,除了一件事......签名从短转换为字节(最后一次测试)

我发现了这个问题,并没有真正从中受益:可移植的有符号/无符号字节转换,C++

这是我的测试:

// test 1 - positive B2Short (success)
byte *b = new byte[2];
b[0] = 0x10; //low byte
b[1] = 0x00; //heigh byte

signed short test = 0;
test = ByteToShort(b);
cout << test << endl;

// test 2 - negative B2Short (success)
b[0] = 0xF0; //low byte
b[1] = 0xFF; //heigh byte

test = 0;
test = ByteToShort(b);
cout << test << endl;

// test 3 - positive Short2B (success)
signed short n = 11;
ShortToByte(n, …
Run Code Online (Sandbox Code Playgroud)

c++ byte short

0
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×1

byte ×1

c++ ×1

contacts ×1

database ×1

short ×1