今天做了什么?
在我们的一个小账本的基础上,定制了数据库。有标签,还有具体的金额
1 package com.example.grouptext02; 2 3 import android.content.Context; 4 import android.database.sqlite.SQLiteDatabase; 5 import android.database.sqlite.SQLiteOpenHelper; 6 import android.util.Log; 7 8 /* 9 * 10 *实现数据库openhelper 11 * 12 * 13 */ 14 public class DataHelper extends SQLiteOpenHelper 15 { 16 final static String DATABASENAME = "my_database.db"; 17 final static int VERSION = 1; 18 final static String TABLENAME = "consumptionInfor"; 19 final static String ID = "id"; 20 21 final static String LABEL = "label"; 22 final static String MONEY = "money"; 23 24 public static final String TAG = "MY_TAG";//日志 25 26 public DataHelper(Context context) 27 { 28 super(context,DATABASENAME,null,VERSION); 29 } 30 31 32 public void onCreate(SQLiteDatabase db) 33 { 34 Log.v(TAG,"王大思的标记1.1"); 35 36 String sql2 = "CREATE TABLE " + 37 TABLENAME + "(" + 38 ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + 39 LABEL + " TEXT," + 40 MONEY + " TEXT);"; 41 Log.v(TAG,"王大思的标记1.2"); 42 db.execSQL(sql2); //创建表 43 Log.v(TAG,"王大思的标记1.3"); 44 } 45 46 public void onUpgrade(SQLiteDatabase arg0,int arg1,int arg2) 47 { 48 Log.v(TAG,"王大思的标记1.3"); 49 } 50 }
这是初期版本,后期预期加入1.备注信息2.消费时间记录
明天准备做什么?
进行主页的开发
遇到的困难!
final static String DATABASENAME = "my_database.db";
final static int VERSION = 1;
final static String TABLENAME = "consumptionInfor";
final static String ID = "id";
final static String LABEL = "label";
final static String MONEY = "money";
此部分信息,上边数据库类型,还有版本基本不需要改变,后面的一般有id然后,接下来就是定义的数据。
时间: 2024-11-05 18:53:24