java - Insert a table of integers - int[] - into SQLite database, -


is possible insert table of integers int[] numbers sqlite table ?

how create column put table?

this line of code:

values.put(mysqlhelper.column_childs, numbers); 

returns me error like:

change type of `numbers` `string` 

there no array datatype in sqlite. have 2 options:

create 2 different tables, "primary" table , "numbers" table, numbers refer record (row) on "primary" table via foreign key.

(easier not ideal): @cloudymarble suggests, use arrays.tostring(numbers) (or stringbuilder if reason doesn't fit needs) put of numbers in array comma-separated string , store in database. can pull value database java array so:

 string[] s = stringfromdb.split(",");  int[] numbers = new int[s.length];  (int curr = 0; curr < s.length; curr++)      numbers[curr] = integer.parseint(s[curr]); 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -