Hey-men-whatsup Hey-men-whatsup - 1 year ago 114
Android Question

source.readList of Parcelable doesn't work over List<String>

This line is red flagged by IDE :


I also changed to


but still wrong, I thought it's because my code was missing getter & setter for
field, but after creating them, it's still wrong. I'm sure this is not the way to make the field parceabled but don't know either the correct way to make correct

Book.java :

public class Book implements Parcelable {
private String bookName;
private int publishTime;
private static List<String> Color = Arrays.asList(new String[]{"red","blue"});

public String getBookName() {
return bookName;

public static List<String> getColor() {
return Color;

public static void setColor(List<String> Color) {
Book.Color = Color;

public void setBookName(String bookName) {
this.bookName = bookName;


public int getPublishTime() {
return publishTime;
public void setPublishTime(int publishTime) {
this.publishTime = publishTime;

public static final Parcelable.Creator<Book> CREATOR = new Creator<Book>() {
public Book createFromParcel(Parcel source) {
Book mBook = new Book();
mBook.bookName = source.readString();
mBook.publishTime = source.readInt();
mBook.Color =source.readList(Color,Book.class.getClassLoader());
return mBook;
public Book[] newArray(int size) {
return new Book[size];
public int describeContents() {
return 0;
public void writeToParcel(Parcel parcel, int flags) {

Answer Source

The problem is that readList returns a void so that might be what your IDE is complaining about. The solution is the following :

 mBook.Color = null;

Hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download