我需要将一个字符串数组保存到数据库中,但它不允许我这样做。这是我的代码:
public long createEntry(String startTime, String endTime, String[] states) {
ContentValues initialValues = new ContentValues();
initialValues.put(START_KEY_TIME , startTime);
initialValues.put(END_KEY_TIME , endTime);
initialValues.put(KEY_STATE, states );
return databaseConnect.insert(DATABASE_TABLE, null, initialValues);
}
但是,如果我输入string[]
states,它会说内容值无法接受参数。我该如何解决这个问题?我想我有7个状态,我能否使用7个单独的字符串并在每个字符串中存储内容,然后将所有字符串放回一个字符串数组中?或者那样做会不好吗?