From c77d0a6f4f55aeedad0a032fddbfd95f9eb038ef Mon Sep 17 00:00:00 2001 From: LinMeng Date: Mon, 8 Jul 2024 11:43:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89Release=201.3=EF=BC=8C=E9=95=BF?= =?UTF-8?q?=E6=8C=89=E6=96=B0UI=E6=96=87=E5=AD=97=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E5=8F=AF=E4=BF=AE=E6=94=B9=E8=83=8C=E6=99=AF=E5=9B=BE=E7=89=87?= =?UTF-8?q?(BETA)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nlchat/fun/ChatCore/ChatFileUtils.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatFileUtils.java diff --git a/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatFileUtils.java b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatFileUtils.java new file mode 100644 index 0000000..8612e70 --- /dev/null +++ b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatFileUtils.java @@ -0,0 +1,36 @@ +/* 受Haohanyh Computer Software Products Open Source LICENSE保护 https://github.com/Hny0305Lin/LICENSE/blob/main/LICENSE */ +package com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore; + +import android.content.Context; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; + +public class ChatFileUtils { + private static final String FILE_NAME = "background_path.txt"; + + public static void saveBackgroundPath(Context context, String path) { + File file = new File(context.getFilesDir(), FILE_NAME); + try (FileWriter writer = new FileWriter(file)) { + writer.write(path); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static String getBackgroundPath(Context context) { + File file = new File(context.getFilesDir(), FILE_NAME); + if (!file.exists()) { + return null; + } + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + return reader.readLine(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } +}