Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Net1314080903115_MySQLiteOpenHelper ——————继承SQLiteOpenHelper类,编写创建数据库流程。
Net1314080903115_Constant————————————在这个类里,定义了一些常量,包括数据库名称、表名称和表的列名
Net1314080903115_Account————————————这个类用于保存Account表的一条记录。
  • Loading branch information
1019940946 authored Jun 16, 2016
1 parent 0ff9473 commit 4323a5c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package edu.hzuapps.androidworks.homeworks.net1314080903115.db;

/**
* Created by lzf on 2016/6/14.
*/
public class Net1314080903115_Account {

public int State=0;//0数据库里没数据,1有数据,还没通过网络验证,2通过网络验证
public int ID;
public String Phone;
public String PassWord;
public String UserName;
public String HeadPortrait;
public String NoteTable;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package edu.hzuapps.androidworks.homeworks.net1314080903115.db;

public class Net1314080903115_Constant {
// 数据库名称
public static final String DATABASE_NAME = "CloudNotes.db";

// 数据库中各表名
public static final String TABLE_Account = "Account";

// Account表
public static final String Account_ID = "ID";
public static final String Account_Phone = "Phone";
public static final String Account_PassWord = "PassWord";
public static final String Account_UserName = "UserName";
public static final String Account_HeadPortrait = "HeadPortrait";
public static final String Account_NoteTable = "NoteTable";

// 笔记表
public static final String NoteTable_ID = "ID";
public static final String NoteTable_Title = "Title";
public static final String NoteTable_Text = "Text";
public static final String NoteTable_Edition = "Edition";
public static final String NoteTable_Date = "Date";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package edu.hzuapps.androidworks.homeworks.net1314080903115.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class Net1314080903115_MySQLiteOpenHelper extends SQLiteOpenHelper {
/*
* 创建数据库
*/
public Net1314080903115_MySQLiteOpenHelper(Context context) {
super(context, Net1314080903115_Constant.DATABASE_NAME, null, 1);
}

// 初始化表
@Override
public void onCreate(SQLiteDatabase db) {
// 创建用户表
db.execSQL("create table " + Net1314080903115_Constant.TABLE_Account + "("
+ Net1314080903115_Constant.Account_ID + " integer primary key not null,"
+ Net1314080903115_Constant.Account_Phone+ " text not null,"
+ Net1314080903115_Constant.Account_PassWord+ " text not null,"
+ Net1314080903115_Constant.Account_UserName + " text not null,"
+ Net1314080903115_Constant.Account_HeadPortrait + " text, "
+ Net1314080903115_Constant.Account_NoteTable + " text not null);");
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

}

}

0 comments on commit 4323a5c

Please sign in to comment.