How to operate the SQLite3 database through the command line

2023-01-25  

在这里插入图片描述
1. First, find the position of Android SDK in this machine. If you don’t know, you can find it at Android Studio, as follows::
在这里插入图片描述
2, followed by CMD, open the Windows command line window. If the directory where the SDK is located is under the C drive, you can directly mount it to the PLATFORM-Tools directory under the SDK directly through the CD command, as follows: below:

cd C:\Users\wyj\AppData\Local\Android\Sdk\platform-tools

If in other disks (such as D disks), you need to transfer to the disk first:
在这里插入图片描述
and then use the CD command to turn to the corresponding position

3, continue, enteradb shellcommand, if the prompt is wrong, it may be because the simulator may not be opened. You can run the simulator in Android Studio

4, then enter the commandsqlite3, you can use SQLite3 database

5. Use.exitcommand to exit SQLite interactive mode

Detailed steps are as follows:
在这里插入图片描述
Another:
You can double-click the SQLite3.exe file under the SQLite3.exe file under the path of Android \ SDK \ Platform-Tools path directly into the final command above!

~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~

1. Create a directory DataBase to save the database file:

\Android\Sdk\platform-toolsUnder the command, enter the following command in turn-

adb root
adb remount

Display at this timeremount succeededmeans successful, you can make the next step
[If promptadb Not running as root. Try "adb root" first., because the selected simulator does not have ROOT, it is best to change a simulator with Google APIS at this time. For details, please refer to this article:Click to view

Then enter the following command in turn-

adb shell
mkdir /data/data/com.example.actualcombatbasis/database

Note-> Abovecom.example.actualcombatbasisis your Android project package name, you have to change to your own, do not fully copy it;databasemeans a folder you want to create, you can customize]

Detailed steps are as follows:
在这里插入图片描述在这里插入图片描述
View effect:
在这里插入图片描述
2. Create or open the database (DB_FIRST):

After theadb shellcommand executes, execute the following commands in turn:

cd /data/data/com.example.actualcombatbasis/database

Note: com.example.actualcombatbasis is your project package name, database is the package where you created, and the default in AS is DataBases.

sqlite3 db_first

Note: Open the database is also the command above

3. Create a database table (user):

create table user (id integer primary key autoincrement,name text not null,pwd text);

4, query all tables:

.tables

5. Insert data into the database table:

insert into user values(null,'wyj','123456');

6, query content in the table:

select * from user;

detailed steps are as follows:
在这里插入图片描述

4 Please like it
(●ˇ∀ˇ●)

source

Random Posts

linux fork function

Experience the practical function of xedit text editor

Video monitoring

OPKG list update failed. Essence Essence Add update source address

ipc message queue system function call source entrance: such as sysmsgsnd