3月2日
Posted 枫叶鎏霜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了3月2日相关的知识,希望对你有一定的参考价值。
记账本
DataBaseHelper.java
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; /** * Created by 惠普 on 2021/2/20. */ public class DatabaseHelper extends SQLiteOpenHelper { public static final String COST_MONEY = "cost_money"; public static final String COST_DATE = "cost_date"; public static final String COST_TITLE = "cost_title"; public static final String IMOOC_COST = "Homework"; public DatabaseHelper(Context context) { super(context, "homework", null, 1); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("create table if not exists Homework(" + "id integer primary key, " + "cost_title varchar, "+ "cost_date varchar, "+ "cost_money varchar)"); } public void insertCost(CostBean costBean){ SQLiteDatabase database=getWritableDatabase(); ContentValues cv=new ContentValues(); cv.put(COST_TITLE,costBean.CostTitle); cv.put(COST_DATE,costBean.CostDate); cv.put(COST_MONEY,costBean.CostMoney); database.insert(IMOOC_COST,null,cv); } public Cursor getAllCostData(){ SQLiteDatabase database=getWritableDatabase(); return database.query(IMOOC_COST, null, null, null, null, null, COST_DATE+" ASC"); } public void deleteAllData(){ SQLiteDatabase database=getWritableDatabase(); database.delete(IMOOC_COST,null,null); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } }
以上是关于3月2日的主要内容,如果未能解决你的问题,请参考以下文章