如何从EditText插入多个记录

时间:2018-07-11 17:17:59

标签: android database sqlite

我想从EditText插入多个记录,并在android的SQlite数据库中插入一个单独的列。

这是我的代码:

   if (rqCode == PICK_CONTACT) {

        if (resultCode == AppCompatActivity.RESULT_OK) {
            Uri contactData = data.getData();
            Cursor c = getContentResolver().query(contactData, null, null, null, null);
            if (c.moveToFirst()) {
                 name = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
                 selected_Names = selected_Names + " " + name;
                String contactId = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
                String hasNumber = c.getString(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));

                if (Integer.valueOf(hasNumber) == 1) {
                    Cursor numbers = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId, null, null);
                    while (numbers.moveToNext()) {
                        selectedNumber = numbers.getString(numbers.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                        selected_Numbers = selected_Numbers + " " + selectedNumber;
              }
      }

我正在尝试将这些联系电话添加到单独的行而不是同一行。

0 个答案:

没有答案