SQLite What happens if I skip over putting a value in column
I have an sqlite table which does not put values in from a string array if
there is nothing to retrieve.
here's the code
//put values from array index in ContentValues till array[4]
//if array.length exceeds 5 put these values in array[5],[6] etc.
values.put(MySQLiteHelper.COLUMN_NAME, words[0]); //adds to column "name"
values.put(MySQLiteHelper.COLUMN_CONTACT, words[1]);
values.put(MySQLiteHelper.COLUMN_DAY1, words[2]);
values.put(MySQLiteHelper.COLUMN_FROM1, words[3]);
//change TO1
if (words[4].equals("0") || words[4].equals("00")){
words[4]="24";
values.put(MySQLiteHelper.COLUMN_TO1, words[4]);
}else{
values.put(MySQLiteHelper.COLUMN_TO1, words[4]);
}
System.out.println("this" +Arrays.toString(words));
//accounting for day 2
if(words.length>5){
values.put(MySQLiteHelper.COLUMN_DAY2, words[5]);
values.put(MySQLiteHelper.COLUMN_FROM2, words[6]);
//change TO2
if (words[7].equals("0") || words[7].equals("00")){
words[7]="24";
values.put(MySQLiteHelper.COLUMN_TO2, words[7]);
}else{
values.put(MySQLiteHelper.COLUMN_TO2, words[7]);
}
}else{
values.putNull(words[5]);
values.putNull(words[6]);
values.putNull(words[7]);
}
when I have values in words[6] and ahead it will make the table but stops
making the table after that. Why can't I put null or not put anything at
all and still make the table work as not all columns are filled in my
table.
No comments:
Post a Comment