I can not install an app on my phone because I see this error :
error: Cannot figure out how to save this field into the database. You can consider adding a type converter for it.
It happens because I have in class This :
@Entity(tableName = "last_state")
public class LastStateTable {
@PrimaryKey(autoGenerate = false)
@ColumnInfo(name = "id")
long id;
@ColumnInfo(name = "date")
String date;
List<Icon> icon;
}
@Entity(tableName = "icon" )
public class Icon {
@PrimaryKey(autoGenerate = false)
@ColumnInfo(name = "id")
int id;
@ColumnInfo(name = "nr")
int nr;
@ColumnInfo(name = "type")
int type;
@ColumnInfo(name = "value")
int value;
}
It cannot install on the device because I have a List inside what I should too?
I try to do this but I have some errors :
public class Converters {
@TypeConverter
public static ArrayList<Icon> fromString(String value) {
Type listType = new TypeToken<ArrayList<Icon>>() {}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String fromArrayList(ArrayList<Icon> list) {
Gson gson = new Gson();
return gson.toJson(list);
}
}