How to save arraylist contents in one column of table in sqlite database in android?

I have an arraist of strings. I need to save this arraylist in 1 column of the database. How can i do this?

+1
source share
2 answers

take a line, add arraylist index line with a loop

String all=""; for(int i=0;i<arraylist.lenght;i++) { all=all+" "+ arraylist.get(i).tostring; } 

now saves "everything" in your DB field, only problem with this: SIZE , hope you have what I had in mind

0
source

You can serialize the object in byte[] and save it in your database as a BLOB or continue encoding in Base64 and save as TEXT . I'm not sure if either of these two is a good way to save your ArrayList - I just specify the parameters.

You can also consider creating another table and emulating the relationships between them. This is a good assessment in databases and is called First Normal Form , but since SQLite is not a relational database, I am not sure about it.

+1
source

Source: https://habr.com/ru/post/1394630/


All Articles