forked from hzuapps/android-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Net1314080903115_MySQLiteOpenHelper ——————继承SQLiteOpenHelper类,编写创建数据库流程。 Net1314080903115_Constant————————————在这个类里,定义了一些常量,包括数据库名称、表名称和表的列名 Net1314080903115_Account————————————这个类用于保存Account表的一条记录。
- Loading branch information
1 parent
0ff9473
commit 4323a5c
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_Account.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
24 changes: 24 additions & 0 deletions
24
...ava/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_Constant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
33 changes: 33 additions & 0 deletions
33
...uapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_MySQLiteOpenHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
|
||
} | ||
|
||
} |