@@ -57,13 +57,13 @@ public static void addContact(Account account, JSONObject contactInfo, ContentRe
5757 e .printStackTrace ();
5858 }
5959
60- if (firstName != null && lastName != null ){
60+ if (! firstName . equals ( " null" ) && ! lastName . equals ( " null" ) ){
6161 displayName = firstName + " " + lastName ;
6262 }
63- else if (firstName != null && lastName .isEmpty ( )){
63+ else if (! firstName . equals ( " null" ) && lastName .equals ( "null" )){
6464 displayName = firstName ;
6565 }
66- else if (lastName != null && firstName .isEmpty ( )){
66+ else if (! lastName . equals ( " null" ) && firstName .equals ( "null" )){
6767 displayName = lastName ;
6868 }
6969
@@ -73,7 +73,7 @@ else if (lastName!=null && firstName.isEmpty()){
7373 ContactsContract .RawContacts .CONTENT_URI , true ))
7474 .withValue (ContactsContract .RawContacts .ACCOUNT_TYPE , account .type )
7575 .withValue (ContactsContract .RawContacts .ACCOUNT_NAME , account .name )
76- .withValue (ContactsContract .RawContacts .RAW_CONTACT_IS_READ_ONLY ,"1" )git
76+ .withValue (ContactsContract .RawContacts .RAW_CONTACT_IS_READ_ONLY ,"1" )
7777 .withValue (ContactsContract .RawContacts .SYNC1 ,contactName )
7878 .withValue (ContactsContract .RawContacts .AGGREGATION_MODE , ContactsContract .RawContacts .AGGREGATION_MODE_DEFAULT )
7979 .build ());
@@ -88,23 +88,23 @@ else if (lastName!=null && firstName.isEmpty()){
8888 .build ());
8989 }
9090
91- if (firstName != null && ! firstName .isEmpty ( )){
91+ if (! firstName .equals ( "null" )){
9292 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
9393 .withValueBackReference (ContactsContract .CommonDataKinds .StructuredName .RAW_CONTACT_ID , 0 )
9494 .withValue (ContactsContract .RawContacts .Data .MIMETYPE , ContactsContract .CommonDataKinds .StructuredName .CONTENT_ITEM_TYPE )
9595 .withValue (ContactsContract .CommonDataKinds .StructuredName .GIVEN_NAME , firstName )
9696 .build ());
9797 }
9898
99- if (lastName != null && ! lastName .isEmpty ( )){
99+ if (! lastName .equals ( "null" )){
100100 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
101101 .withValueBackReference (ContactsContract .CommonDataKinds .StructuredName .RAW_CONTACT_ID , 0 )
102102 .withValue (ContactsContract .RawContacts .Data .MIMETYPE , ContactsContract .CommonDataKinds .StructuredName .CONTENT_ITEM_TYPE )
103103 .withValue (ContactsContract .CommonDataKinds .StructuredName .FAMILY_NAME , lastName )
104104 .build ());
105105 }
106106 // add phone number
107- if (phone != null && ! phone .isEmpty ( )) {
107+ if (! phone .equals ( "null" )) {
108108 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
109109 .withValueBackReference (ContactsContract .CommonDataKinds .Phone .RAW_CONTACT_ID , 0 )
110110 .withValue (ContactsContract .Data .MIMETYPE ,ContactsContract .CommonDataKinds .Phone .CONTENT_ITEM_TYPE )
@@ -114,7 +114,7 @@ else if (lastName!=null && firstName.isEmpty()){
114114 }
115115
116116 //add mobile number
117- if (mobileNo != null && ! mobileNo .isEmpty ( )) {
117+ if (! mobileNo .equals ( "null" )) {
118118 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
119119 .withValueBackReference (ContactsContract .CommonDataKinds .Phone .RAW_CONTACT_ID , 0 )
120120 .withValue (ContactsContract .Data .MIMETYPE ,ContactsContract .CommonDataKinds .Phone .CONTENT_ITEM_TYPE )
@@ -124,7 +124,7 @@ else if (lastName!=null && firstName.isEmpty()){
124124 }
125125
126126 //add email
127- if (emailID != null && ! emailID .isEmpty ( )) {
127+ if (! emailID .equals ( "null" )) {
128128 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
129129 .withValueBackReference (ContactsContract .CommonDataKinds .Email .RAW_CONTACT_ID , 0 )
130130 .withValue (ContactsContract .Data .MIMETYPE ,ContactsContract .CommonDataKinds .Email .CONTENT_ITEM_TYPE )
@@ -134,7 +134,7 @@ else if (lastName!=null && firstName.isEmpty()){
134134 }
135135
136136 //add Customer
137- if (customerName != null && ! customerName .isEmpty ( )){
137+ if (! customerName .equals ( "null" )){
138138 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
139139 .withValueBackReference (ContactsContract .CommonDataKinds .Organization .RAW_CONTACT_ID , 0 )
140140 .withValue (ContactsContract .Data .MIMETYPE ,ContactsContract .CommonDataKinds .Organization .CONTENT_ITEM_TYPE )
@@ -143,7 +143,7 @@ else if (lastName!=null && firstName.isEmpty()){
143143 }
144144
145145 //add Supplier
146- if (supplierName != null && ! supplierName .isEmpty ( )){
146+ if (! supplierName .equals ( "null" )){
147147 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
148148 .withValueBackReference (ContactsContract .CommonDataKinds .Organization .RAW_CONTACT_ID , 0 )
149149 .withValue (ContactsContract .Data .MIMETYPE ,ContactsContract .CommonDataKinds .Organization .CONTENT_ITEM_TYPE )
@@ -152,7 +152,7 @@ else if (lastName!=null && firstName.isEmpty()){
152152 }
153153
154154 //add Sales Partner
155- if (salePartnerName != null && ! salePartnerName .isEmpty ( )){
155+ if (! salePartnerName .equals ( "null" )){
156156 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
157157 .withValueBackReference (ContactsContract .CommonDataKinds .Organization .RAW_CONTACT_ID , 0 )
158158 .withValue (ContactsContract .Data .MIMETYPE ,ContactsContract .CommonDataKinds .Organization .CONTENT_ITEM_TYPE )
@@ -161,7 +161,7 @@ else if (lastName!=null && firstName.isEmpty()){
161161 }
162162
163163 //add Department
164- if (department != null && ! department .isEmpty ( )){
164+ if (! department .equals ( "null" )){
165165 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
166166 .withValueBackReference (ContactsContract .CommonDataKinds .Organization .RAW_CONTACT_ID , 0 )
167167 .withValue (ContactsContract .Data .MIMETYPE ,ContactsContract .CommonDataKinds .Organization .CONTENT_ITEM_TYPE )
@@ -170,7 +170,7 @@ else if (lastName!=null && firstName.isEmpty()){
170170 }
171171
172172 //add Designation
173- if (designation != null && ! designation .isEmpty ( )){
173+ if (! designation .equals ( "null" )){
174174 op_list .add (ContentProviderOperation .newInsert (ContactsContract .Data .CONTENT_URI )
175175 .withValueBackReference (ContactsContract .CommonDataKinds .Organization .RAW_CONTACT_ID , 0 )
176176 .withValue (ContactsContract .Data .MIMETYPE ,ContactsContract .CommonDataKinds .Organization .CONTENT_ITEM_TYPE )
0 commit comments