ContentValues和Hash Table都是一种存储的机制。两者的区别在于,contentValues只能存储基本类型的数据,String,int之类的,不能存储对象,而Hash Table却可以存储对象。
把数据插入数据库中时,首先要有一个ContentValues的对象:
ContentValues contentValues = new ContentValues();
contentValues.put(key,values);
SQLiteDataBase sdb;
sdb.insert(database_name,null,initialValues);
成功插入则返回记录的id,否则返回-1。