Search
 
SCRIPT & CODE EXAMPLE
 

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;
    }
}
Comment

save ArrayList into Room Database android studio

@Database (entities = {MainActivityData.class},version = 1)
@TypeConverters({Converters.class})
Comment

PREVIOUS NEXT
Code Example
Java :: how to extract a set of binary strings in java 
Java :: open bottomsheet from adapter java 
Java :: what does % do in java 
Java :: Java Creating LinkedHashMap from Other Maps 
Java :: navigation view item selected 
Java :: how to scroll down chrome browser in selenium java 
Java :: tests offline cypress 
Java :: java data table source tymeLeaf 
Java :: public static void trong java là gì 
Java :: how to get the last vowel of a string in java 
Java :: session-less control using java 
Java :: Error: Could not find or load main class mcp.client.Start Caused by: java.lang.ClassNotFoundException: mcp.client.Start 
Java :: stringbuffer concatenation in java 
Java :: Which one of the following values can a Java variable NOT have? 
Java :: How can i stub Instant object using powermock 
Java :: how to make factorial in java recursive 
Java :: reset status bar color in android 
Java :: change FS to hdfs java 
Java :: short array in java 
Java :: java startActivity crash 
Java :: LayerRenderer 
Java :: how do I change the opacity of a JButton 
Java :: compare time in java 
Java :: throw keyword in java 
Java :: java lambda 
Java :: top easiest languages programming to learn 
Java :: java printstacktrace 
Java :: springboot avoid generated security password: 
Java :: ArrayIndexOutOfBoundsException 
Java :: array srting line by line in textview android 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =