安卓---第5章 数据存储---保存QQ账号与密码

文章介绍了在Android应用中保存QQ账号和密码的两种方法:一是使用文件存储,通过`FileSaveQQ`类实现数据的写入和读取;二是利用SharedPreferences进行存储,通过`SPSaveQQ`类管理账号和密码。这两种方法都是Android中常见的数据持久化技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

案例1: 使用文件存储 保存QQ账号与密码

功能描述

在这里插入图片描述
在这里插入图片描述

saveqq_1.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#E6E6E6"
    android:orientation="vertical"
    android:padding="10dp">

    <!--    头像-->
    <ImageView
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="30dp"
        android:src="@drawable/zh_21" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:background="@color/white"
        android:orientation="horizontal">
        <!--        TextView控件用于显示"账号"、"密码"的文本信息-->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:text="账号"
            android:textColor="#000"
            android:textSize="20sp" />
        <!--EditText用于输入账号、密码的输入框-->
        <EditText
            android:id="@+id/et_account"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:background="@null"
            android:padding="10dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:background="@color/white"
        android:orientation="horizontal">
        <!--        TextView控件用于显示"账号"、"密码"的文本信息-->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:text=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值