Reputation: 71
I am trying to use the Android ez vcard library to create vcf file from my object. My problem is I have no idea how to instantiate a List
of VCards, like so:
List<VCard> vcards = null ;
I tried:
List<VCard> vcards = new List<VCard>();
but then it insists on implementing methods to look like this:
List<VCard> vcards = new List<VCard>() {
@Override
public void add(int location, VCard object) {
}
@Override
public boolean add(VCard object) {
return false;
}
@Override
public boolean addAll(int location, Collection<? extends VCard> collection) {
return false;
}
@Override
public boolean addAll(Collection<? extends VCard> collection) {
return false;
}
@Override
public void clear() {
}
@Override
public boolean contains(Object object) {
return false;
}
@Override
public boolean containsAll(Collection<?> collection) {
return false;
}
@Override
public VCard get(int location) {
return null;
}
@Override
public int indexOf(Object object) {
return 0;
}
@Override
public boolean isEmpty() {
return false;
}
@NonNull
@Override
public Iterator<VCard> iterator() {
return null;
}
@Override
public int lastIndexOf(Object object) {
return 0;
}
@Override
public ListIterator<VCard> listIterator() {
return null;
}
@NonNull
@Override
public ListIterator<VCard> listIterator(int location) {
return null;
}
@Override
public VCard remove(int location) {
return null;
}
@Override
public boolean remove(Object object) {
return false;
}
@Override
public boolean removeAll(Collection<?> collection) {
return false;
}
@Override
public boolean retainAll(Collection<?> collection) {
return false;
}
@Override
public VCard set(int location, VCard object) {
return null;
}
@Override
public int size() {
return 0;
}
@NonNull
@Override
public List<VCard> subList(int start, int end) {
return null;
}
@NonNull
@Override
public Object[] toArray() {
return new Object[0];
}
@NonNull
@Override
public <T> T[] toArray(T[] array) {
return null;
}
} ;
and when I try to add vcards to it, I get a NullPointerException. How do I solve this?
Upvotes: 0
Views: 501
Reputation: 1986
Try this
List<VCard> vcards = new ArrayList<VCard>();
Hope it helps.
Upvotes: 1