Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

save ArrayList into Room Database android studio

public class Converters {
    @TypeConverter
    public static ArrayList<String> fromString(String value) {
        Type listType = new TypeToken<ArrayList<String>>() {}.getType();
        return new Gson().fromJson(value, listType);
    }

    @TypeConverter
    public static String fromArrayList(ArrayList<String> list) {
        Gson gson = new Gson();
        String json = gson.toJson(list);
        return json;
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #save #ArrayList #Room #Database #android #studio
ADD COMMENT
Topic
Name
1+3 =