Skip to content

Commit

Permalink
🎉Release 1.2,修复SQL消息表中消息和时间戳一起写入的逻辑问题(BETA)、修改SQL相关代码、修复SQL逻辑Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Hny0305Lin committed Jul 2, 2024
1 parent 8d01693 commit 570d087
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void CreateSql(String SDPath) {
createVersionTable();
}

//创建消息表,存储消息、相关用户、聊天时间,绑定ID
private void createChatTable() {
String TABLE_CREATE =
"CREATE TABLE IF NOT EXISTS messages (" +
Expand All @@ -34,6 +35,7 @@ private void createChatTable() {
sqLiteDataBaseForAPP.execSQL(TABLE_CREATE);
}

//创建版本表,存储聊天消息时使用该软件的版本号,绑定ID
private void createVersionTable() {
String TABLE_CREATE =
"CREATE TABLE IF NOT EXISTS versions (" +
Expand All @@ -42,6 +44,7 @@ private void createVersionTable() {
sqLiteDataBaseForAPP.execSQL(TABLE_CREATE);
}

//保存消息到数据库
public void saveMessageToDatabase(String message, String sender, String timestamp) {
ContentValues values = new ContentValues();
values.put("message", message);
Expand All @@ -50,12 +53,14 @@ public void saveMessageToDatabase(String message, String sender, String timestam
sqLiteDataBaseForAPP.insert("messages", null, values);
}

//保存版本号到数据库
public void saveVersionToDatabase(String version) {
ContentValues values = new ContentValues();
values.put("version", version);
sqLiteDataBaseForAPP.insert("versions", null, values);
}

//获取表中消息,按时间戳升序排序
public Cursor getAllMessages() {
return sqLiteDataBaseForAPP.query("messages", null, null, null, null, null, "timestamp ASC");
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>
<string name="app_name">NLChat</string>
<string name="app_package">com.haohanyh.linmengjia.nearlink.nlchat.fun</string>
<string name="app_version">1.2.86.2024.0703</string>
<string name="app_version">1.2.93.2024.0703</string>

<string name="appwarn">NLChat,浩瀚银河宗旨为用爱和魔法创造Android APP。</string>
<string name="thanks3q">友情感谢</string>
Expand Down

0 comments on commit 570d087

Please sign in to comment.