How to add new elements to an array?

后端 未结 18 1909
误落风尘
误落风尘 2020-11-22 04:55

I have the following code:

String[] where;
where.append(ContactsContract.Contacts.HAS_PHONE_NUMBER + \"=1\");
where.append(ContactsContract.Contacts.IN_VISIB         


        
18条回答
  •  余生分开走
    2020-11-22 05:30

    If you would like to store your data in simple array like this

    String[] where = new String[10];
    

    and you want to add some elements to it like numbers please us StringBuilder which is much more efficient than concatenating string.

    StringBuilder phoneNumber = new StringBuilder();
    phoneNumber.append("1");
    phoneNumber.append("2");
    where[0] = phoneNumber.toString();
    

    This is much better method to build your string and store it into your 'where' array.

提交回复
热议问题