• 家庭记账本第七次


    package com.example.jizhangben;
    
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    
    public class CostDB extends SQLiteOpenHelper {
    
        public static final String TABLE_NAME = "costs";
        public static final String MONEY = "money";
        public static final String DATE = "date";
        public static final String TITLE = "title";
    
        public CostDB(Context context) {
            super(context, "costs1", null, 1);
        }
    
        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL("create table if not exists "+ TABLE_NAME +"("+
                    "id integer primary key, "+
                    "title varchar, "+
                    "date varchar, "+
                    "money varchar)");
        }
        public void insertCost(costBean costBean1)
        {
            SQLiteDatabase database=getWritableDatabase();
            ContentValues cv=new ContentValues();
            cv.put(TITLE,costBean1.costTitle);
            cv.put(DATE,costBean1.costDate);
            cv.put(MONEY,costBean1.costMoney);
            database.insert("TABLE_NAME",null,cv);
        }
        public Cursor getAllCostData(){
            SQLiteDatabase database = getReadableDatabase();
            return database.query("TABLE_NAME",null,null,null,null,null,null);
        }
        public void deleteAllData(){
            SQLiteDatabase database=getWritableDatabase();
            database.delete("TABLE_NAME",null,null);
        }
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    
        }
    }
  • 相关阅读:
    关于网络字节序(network byte order)和主机字节序(host byte order)
    关于垃圾回收,我来解释下为什么LocalConnection可以实现垃圾回收
    解决Form中ExternalInterface的Bug问题
    AS3里var aa:String是null还是""?
    IE并发连接限制(as)
    tar
    mysql默认端口号3306
    flex经验
    这个游戏不错
    nginx介绍
  • 原文地址:https://www.cnblogs.com/chaogehahaha/p/14915585.html
Copyright © 2020-2023  润新知