zoukankan      html  css  js  c++  java
  • Android SQLite

    private MySQLiteOpenHelper dbHelper=null;
    int version = 1;
       
    //table name
    String tables[]={"t_favorateExposant"};
    //fields’ name of the table
    String fieldNames[][] =
    {
        { "f_id", "f_name", "f_stand", "f_activity", "f_present", "f_tel", "f_fax", "f_email", "f_website"}
    };
    //fields’ type of the table
    String fieldTypes[][] =
    {
        { "INTEGER PRIMARY KEY AUTOINCREMENT", "text", "text", "text", "text", "text", "text", "text", "text"}
    };
    //columns’name, for which we search the values  
    String resultColumn[] = {"f_id", "f_name"};
    //create database
    dbHelper = new MySQLiteOpenHelper(this, "dbSalon", null, version, tables, fieldNames, fieldTypes);
    //recherché
    String selectionArgs[] = {selectedExpoName};
    Cursor c = dbHelper.select(tables[0], resultColumn, "f_name=?", selectionArgs, null, null, null);
     
    //delete
    if (c.moveToFirst())
    {
            String where = "f_id=?";
            String whereValue[] = {c.getString(0)};
            int col = dbHelper.delete(tables[0], where, whereValue);
            holder.star.setImageResource(R.drawable.p03a_exposants_checkbox);
    }
     
    //insert
    else
    {
        String f2[] = {"f_name", "f_stand", "f_activity", "f_present", "f_tel", "f_fax", "f_email", "f_website"};
        for (int i = 0; i < exposantList.size();i++)
        {
           if(!exposantList.get(i).getSociete().equals(selectedExpoName))
            {continue;}
                            
           activity = exposantList.get(i).getActivite();
           present = exposantList.get(i).getPresentation();
           tel = exposantList.get(i).getTelephone();
           fax = exposantList.get(i).getFax();
           email  = exposantList.get(i).getEmail();
           website = exposantList.get(i).getAdresseSiteWeb();
        }
                           
        String value[] = {selectedExpoName,selectedStand,activity,present,tel,fax,email,website};
        long rowid = dbHelper.insert(tables[0], f2, value);
        holder.star.setImageResource(R.drawable.p03a_exposants_checkbox_selected);
    }
  • 相关阅读:
    前端响应式开发
    前端兼容性问题解决方案(二)
    web storage
    flex布局 滚动条失效
    ant-design-vue form表单 defaultValue默认值
    node express 中间件 http-proxy-middleware 和 express-http-proxy 转发 搞定 post 超时
    Math.min & Math.max & apply
    Backbone源码分析-noConflict
    安卓下浏览器(包括微信)video 小窗口播放
    前端工作流
  • 原文地址:https://www.cnblogs.com/qionglouyuyu/p/4620220.html
Copyright © 2011-2022 走看看