• 家庭记账本第七次


    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) {
    
        }
    }
  • 相关阅读:
    gevent实现基于epoll和协程的服务器
    用greenlet实现协程消费者生产者
    More is better(MST)(求无向图中最大集合元素个数)
    小希的迷宫(MST单棵树判断法则)
    畅通工程再续(MST)
    畅通工程再续
    畅通工程
    还是畅通工程(MST)
    Minimum Inversion Number
    Who Gets the Most Candies?(线段树 + 反素数 )
  • 原文地址:https://www.cnblogs.com/chaogehahaha/p/14915585.html
Copyright © 2020-2023  润新知