如何在SQLite数据库中只插入一个用户名和密码? [英] How to insert only one username and password in SQLite database?

查看:384
本文介绍了如何在SQLite数据库中只插入一个用户名和密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我有两个文本字段和一个按钮。在第一个文本字段中,我输入用户的用户名,在第二个文本字段中,我输入用户的密码。当用户输入用户名和密码并单击创建用户按钮时,将调用后端api,该api将注册用户的用户名和密码,当时我想在本地SQLite数据库中输入用户的用户名和密码格式。

I have an application where I have two textfields and a button. In the first textfield I am entering the username of the user and in the second textfield I am entering the password of the user. When the user enters the username and password and click on create user button a backend api is called which will register the username and password of the user and at the time I want to enter the username and password of the user in local SQLite databse in encrypted format.

当用户注册时,该特定用户的用户名应该显示在第一个文本字段中,并且不应该是可编辑的,密码字段应该是可编辑的。只允许一个用户注册整个应用程序。

When a user is registered the username of that particular user should get displayed in the first textfield and it should not be editable and password field should be editable. Only one user is allowed to be registered for the entire application.

推荐答案

如果我理解您的要求,您可以按照以下指南。

If I understood your requirement correctly, You can follow the below guideline.

在将数据插入表之前,您可以检查是否有任何记录添加到表中。

如果计数为0,则可以继续插入记录,否则你可以提示错误。

Before inserting the data to the table, You can check if any record is added to the table.
If the count is 0, you can proceed to insert the record, else you can prompt the error.

我认为这是最简单的方法。

I think this will be the simplest way to do this.

这篇关于如何在SQLite数据库中只插入一个用户名和密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆