zoukankan      html  css  js  c++  java
  • ContentValues 和HashTable之间的区别

    ContentValues  

    This class is used to store a set of values that the ContentResolver can process.

    用于保存一些数据(string boolean byte double float int long  short ...)信息,这些信息可以被数据库操作时使用。

    ContentValues() Creates an empty set of values using the default initial size

    ContentValues(int size) Creates an empty set of values using the given initial size

    ContentValues(ContentValues from) Creates a set of values copied from the given set

    ContentValues 和HashTable

    ContentValues 和HashTable类似都是一种存储的机制但是两者最大的区别就在于,contenvalues只能存储基本类型的数据,像string,int之类的,不能存储对象这种东西,而HashTable却可以存储对象。

    在往数据库中插入数据的时候,首先应该有一个ContentValues的对象所以:

    ContentValues initialValues = new ContentValues();

    initialValues.put(key,values);

    SQLiteDataBase sdb ;

    sdb.insert(database_name,null,initialValues);

    插入成功就返回记录的id否则返回-1;

  • 相关阅读:
    48. 旋转图像(顺时针)
    560. 和为K的子数组
    75. 颜色分类(三指针移动||计数排序)
    670. 最大交换
    常见端口号汇总
    springboot解决跨域问题跨域
    jad使用
    tomcat9:解决tomcat catalina log和localhost log中文乱码
    JUC:阻塞队列
    JUC:读写锁
  • 原文地址:https://www.cnblogs.com/renkangke/p/3019830.html
Copyright © 2011-2022 走看看