- 浏览: 870926 次
- 性别:
- 来自: 上海
-
最新评论
-
waterflow:
感谢分享
简单的ChartDirector生成图表例子 -
YQuite:
写到最后一种文件才看到这个,洼的一声哭了出来 - - !
java简单解析docx、pptx、xlsx文档 -
q394469902:
Android通过selector改变界面状态 -
db6623919:
直接粘贴别人帖子还是英文的,有意思?
实现RTSP协议的简单例子 -
ykou314:
请问下,这些超级命令,是否需要android root权限,尤 ...
Android系统在超级终端下必会的命令大全(七)
SQLite is available on the Android device itself. The executable is in the /system/bin directory of the device. You can see that this directory contains the shell commands like ls, ps, etc., as well as sqlite3, dalvikvm, and dexdump utilities.
Code Listing 1. Contents of system/bin
# pwd
pwd
/system/bin
# ls -l
ls -l
-rwxr-xr-x root root 196 2008-02-29 01:09 am
-rwxr-xr-x root root 2342 2008-02-29 01:09 dumpstate
-rwxr-xr-x root root 208 2008-02-29 01:09 input
-rwxr-xr-x root root 212 2008-02-29 01:09 monkey
-rwxr-xr-x root root 196 2008-02-29 01:09 pm
…
lrwxr-xr-x root root 2008-02-29 01:16 mount -> toolbox
lrwxr-xr-x root root 2008-02-29 01:16 notify -> toolbox
-rwxr-xr-x root root 28032 2008-02-29 01:16 dexdump
-rwxr-xr-x root root 7100 2008-02-29 01:16 dumpsys
-rwxr-xr-x root root 7904 2008-02-29 01:16 mem_profiler
-rwxr-xr-x root root 6480 2008-02-29 01:16 service
-rwxr-xr-x root root 4320 2008-02-29 01:16 rild
-rwxr-xr-x root root 4928 2008-02-29 01:16 sdutil
-rwxr-xr-x root root 26488 2008-02-29 01:16 sqlite3
-rwxr-xr-x root root 4148 2008-02-29 01:16 dexopt
-rwxr-xr-x root root 4908 2008-02-29 01:16 dalvikvm
-rwsr-sr-x root root 3200 2008-02-29 01:16 surfaceflinger
-rwxr-xr-x root root 5420 2008-02-29 01:16 app_process
-rwxr-xr-x root root 39408 2008-02-29 01:16 runtime
-rwxr-xr-x root root 2920 2008-02-29 01:16 system_server
-rwxr-xr-x root root 9168 2008-02-29 01:17 pv
Where are the SQLite databases on an Android Device?
By default, the SQLite databases have an extension .db. For example, a NotePad application may use note_pad.db database. This might be created from code using Android SDK’s SQLite classes/methods. By default, the SQLite database for an application is in the /data/data/<app>/databases directory. As you can see from the listing below, the notepad database is in the /data/data/com.google.android.notepad/databases directory.
Code Listing 2. The location of the notepad database
# pwd
pwd
/data/data/com.google.android.notepad/databases
# ls -l
ls -l
-rw-rw---- app_8 app_8 3072 2008-03-18 18:23 note_pad.db
You can see a whole bunch of these sub-directories under the /data/data directory.
Code Listing 3. The /data/data directory
# pwd
pwd
/data/data
# ls
ls
com.google.android.notepad
com.google.android.samples
com.google.android.gtalkservice
com.google.android.phone
com.google.android.maps
com.google.android.providers.im
com.google.android.home
com.google.android.googleapps
com.google.android.gtalksettings
com.google.android.fallback
com.google.android.development
com.google.android.contacts
com.google.android.browser
com.google.android.providers.telephony
com.google.android.providers.settings
com.google.android.providers.media
com.google.android.masfproxyservice
com.google.android.providers.googleapps
com.google.android.providers.contacts
android
Starting the SQLite command line program
Starting generically
Typing sqlite3 in the Android Shell will open the SQLite command line program (since sqlite3 is in the /system/bin directory). Typing .help gives the summarized set of commands available from here.
Code Listing 4. The SQLite commands available from the command line utility
# sqlite3
sqlite3
SQLite version 3.5.0
Enter ".help" for instructions
sqlite> .help
.help
.bail ON|OFF Stop after hitting an error. Default OFF
.databases List names and files of attached databases
.dump ?TABLE? ... Dump the database in an SQL text format
.echo ON|OFF Turn command echo on or off
.exit Exit this program
.explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
.header(s) ON|OFF Turn display of headers on or off
.help Show this message
.import FILE TABLE Import data from FILE into TABLE
.indices TABLE Show names of all indices on TABLE
.load FILE ?ENTRY? Load an extension library
.mode MODE ?TABLE? Set output mode where MODE is one of:
csv Comma-separated values
column Left-aligned columns. (See .width)
html HTML <table> code
insert SQL insert statements for TABLE
line One value per line
list Values delimited by .separator string
tabs Tab-separated values
tcl TCL list elements
.nullvalue STRING Print STRING in place of NULL values
.output FILENAME Send output to FILENAME
.output stdout Send output to the screen
.prompt MAIN CONTINUE Replace the standard prompts
.quit Exit this program
.read FILENAME Execute SQL in FILENAME
.schema ?TABLE? Show the CREATE statements
.separator STRING Change separator used by output mode and .import
.show Show the current values for various settings
.tables ?PATTERN? List names of tables matching a LIKE pattern
.timeout MS Try opening locked tables for MS milliseconds
.width NUM NUM ... Set column widths for "column" mode
sqlite>
Opening a database
You would, of course, want to see the data and structure of a particular database. In the listing below, the note_pad.db is opened for further querying. Here, I went to the directory where the database is; however, you can also specify the full path.
Code Listing 5. Opening a specific database from SQLite command line
# pwd
pwd
/data/data/com.google.android.notepad/databases
# ls
ls
note_pad.db
# sqlite3 note_pad.db
sqlite3 note_pad.db
SQLite version 3.5.0
Enter ".help" for instructions
sqlite>
Example Commands from the SQLite command line program
Getting the list of tables
You can get the list of all the tables in the current database in two ways: from the .tables command or by querying the sqlite_master table.
Code Listing 6. List of tables
sqlite> .tables
.tables
android_metadata notes
sqlite> select * from sqlite_master;
select * from sqlite_master;
table|android_metadata|android_metadata|2|CREATE TABLE android_metadata (locale
TEXT)
table|notes|notes|3|CREATE TABLE notes (_id INTEGER PRIMARY KEY,title TEXT,note
TEXT,created INTEGER,modified INTEGER)
Getting the schema of the tables
By using the .schema command, you can get the schema of either all of the tables or a single table.
Code Listing 7. Schema of tables
sqlite> .schema
.schema
CREATE TABLE android_metadata (locale TEXT);
CREATE TABLE notes (_id INTEGER PRIMARY KEY,title TEXT,note TEXT,created INTEGER
,modified INTEGER);
sqlite> .schema notes
.schema notes
CREATE TABLE notes (_id INTEGER PRIMARY KEY,title TEXT,note TEXT,created INTEGER
,modified INTEGER);
SQL Queries
You can issue queries like ‘select * from notes’ to get the data from the notes table. As you can see from the figure below, I have entered a series of notes in the notepad application.
Figure 1. Notes in the Note pad application
After entering the notes, if you query the notes table, you will get the data in the _id, title, note, created, and modified columns.
Code Listing 8. Data from notes
sqlite> .schema notes
.schema notes
CREATE TABLE notes (_id INTEGER PRIMARY KEY,title TEXT,note TEXT,created INTEGER
,modified INTEGER);
sqlite> select * from notes;
select * from notes;
1|Title of Note
This is a test note.|This is a test note.|1205871448827|1205873944838
3|Another note
Some text.|A third note
Some text.|1205873990394|1205874145996
4|One more
Body here|One more
Body here|1205874074992|1205874088072
And, finally, we can take a look at how this table was created.
Code Listing 9. Creation of the notes table
public class NotePadProvider extends ContentProvider {
…
private static class DatabaseHelper extends SQLiteOpenHelper {
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE notes (_id INTEGER PRIMARY KEY,"
+ "title TEXT," + "note TEXT," + "created INTEGER,"
+ "modified INTEGER" + ");");
}
…
}
…
@Override
public boolean onCreate() {
DatabaseHelper dbHelper = new DatabaseHelper();
mDB = dbHelper.openDatabase(getContext(), DATABASE_NAME, null, DATABASE_VERSION);
return (mDB == null) ? false : true;
}
…
}
As you can see above, CREATE TABLE sql has been used to create the notes table. Classes like SQLiteOpenHelper and ContentProvider from Android SDK are put to use here.
发表评论
-
One省电卫士 - Android内核级省电App
2013-02-03 19:32 3589One省电卫士是一款androi ... -
(转)Windows下Eclipse集成Cygwin配置Android NDK环境编译JNI库程序步骤
2012-05-09 16:11 5609前戏准备: 1. 搭建Eclipse Android ... -
Android-Task和Activity相关的一些属性[转]
2011-08-23 09:21 3074android:allowTaskReparenting用来标 ... -
GC_FOR_MALLOC
2011-07-01 11:44 2305GC_FOR_MALLOC means that the ... -
ProgressBar 样式
2011-05-01 23:06 3175The four attributes that you me ... -
ShellCommand.java
2011-04-07 19:38 1600/** * ShellCommand.java runs co ... -
Android任务管理终极发布AndTask 3.1(安安任务管理)
2011-04-04 07:50 1686安安任务管理是一款android任务管理软件,可通过手动或自动 ... -
AndMemory 安安内存管理 1.1 发布
2011-03-08 23:42 1910AndMemory is an android memory ... -
预测今年将是android应用普及年和android安全年
2011-03-06 21:53 1992经过去年一年的实践,预测今年将是android应用 ... -
Android之混淆(Obfuscate)
2011-03-06 16:07 2923下载Android安安软件请到:http://code. ... -
Android内存信息
2011-02-21 21:40 2175下载Android安安软件请到:http://code.goo ... -
How to decompile .dex file on Android(转)如何反编译.dex文件
2011-02-20 11:34 2908下载Android安安软件请到:http://code.goo ... -
(转)android JNI 学习笔记1
2011-02-17 10:08 2818下载Android安安软件请到:http://code.goo ... -
(转)Android内存管理机制之一:lowmemory killer
2011-02-15 15:00 2646下载Android安安软件请到 ... -
(转)内存管理Memory Management in Android
2011-02-14 23:31 4207下载Android安安软件请到:http://code.goo ... -
转-Andriod被排出Linux内核的原因
2011-01-12 22:36 1545下载Android安安软件请到:http://code.goo ... -
Ubuntu 开启 Android 的 USB 调试模式
2011-01-06 20:51 7810在Android开发者网站中, 它提供了在 Ubuntu 下实 ... -
解决Conversion to Dalvik format failed: Unable to execute dex: null
2010-12-12 23:17 2418解决Conversion to Dalvik format f ... -
AndBox发布最新版AndRootFile(安安文件管理) 3.0 beta 版
2010-11-27 09:56 1785The ultimate file manager for r ... -
(转)区分Activity的四种加载模式
2010-11-20 10:09 1819在多Activity开发中,有可能是自己应用之间的Activi ...
相关推荐
这篇博客“Android SQLite学习工具”可能详细介绍了如何在Android环境中使用SQLite进行数据操作,并提供了一个实用的SQLite管理工具——sqlite3.exe。 SQLite数据库在Android中的应用主要包括创建数据库、创建表、...
5. **使用ADB shell**:通过ADB连接到设备,然后在shell环境下运行sqlite3命令,这样可以避免因环境配置不全导致的问题。 6. **第三方工具**:有些第三方工具,如SQLiteManager,提供了图形化的界面来管理SQLite...
相当简单Android SQLite数据库增删改查,绝对适合新手,包您一看就会, 1.这是我照着网上的资料和帮助手册写的; 2.数据库的增删改查都涉及到了; 3.导入项目,运行,然后 在终端进入数据库,命令为 adb shell cd ...
本文将详细介绍如何使用Android shell(通常简称adb shell)命令来创建一个SQLite数据库,并进行基本的操作。 #### 二、环境准备与配置 在开始之前,确保已经安装了Android SDK Platform Tools,并将其添加到系统...
### Android ADB Shell 命令详解 #### 1. 显示系统中全部 Android 平台 - **命令**: `android list targets` - **描述**: 此命令用于列出所有可用的 Android 平台版本,这对于选择合适的开发环境非常重要。 - **...
此外,Android SDK提供了一个叫做`adb shell sqlite3`的命令,可以直接在adb命令行中与设备上的SQLite数据库交互,但该版本可能不适用于所有Android版本,因此,从特定版本的AVD中提取并使用的SQLite3可执行文件可能...
Android提供了`adb shell`命令,可以导出和导入SQLite数据库,方便在开发过程中备份和恢复数据。 9. **LiveData与Room库** Google推出的Room库是对SQLite的现代封装,提供了更高级别的抽象,如`LiveData`,使得...
SQLite实质上是将数据写入一个文件,通常情况下,在应用的包名下面都能找到xxx.db的文件,拥有root权限的手机,可以通过adb shell,看到data/data/packagename/databases/xxx.db这样的文件。我们可以得知SQLite是...
标题中的“sqlite3和libncurses.so”涉及到的是在Android环境中使用SQLite数据库管理工具和一个必要的库文件。SQLite是一个轻量级的关系型数据库管理系统,广泛应用于移动设备,如Android手机和平板,因为它不需要...
在Android平台上,SQLite3是一个非常重要的数据库管理系统,用于存储应用程序中的结构化数据。SQLite3作为一个轻量级的数据库,不需要独立的服务器进程,且能够直接嵌入到Android应用中,使得开发者可以方便地进行...
在Android系统上使用SQLite3时,需通过`adb shell`命令进入设备的shell环境,再调用SQLite3命令。若要操作特定的应用数据库,如`settings.db`,可以直接指定数据库文件的完整路径。此外,通过组合使用`su`命令获取...
在Android系统中,SQLite是一个轻量级的数据库引擎,它被广泛用于移动应用来存储数据。当我们在Android设备上进行应用程序开发或者进行调试时,有时需要直接与SQLite数据库交互,例如查询、修改或分析数据。在这样的...
在Android系统中,SQLite是一个内置的关系型数据库管理系统,用于存储应用程序的数据。SQLite支持SQL标准,具有轻量级、高效、可靠的特点,使得它成为移动应用数据管理的理想选择。本主题将深入探讨如何在Android中...
10. **与其他应用集成**:许多应用程序,如Android、iOS和桌面应用,都内置了SQLite支持,使得在这些平台上集成SQLite变得非常容易。 以上就是SQLite创建数据库的基本流程和主要操作,通过熟悉这些知识,开发者可以...
- 管理SQLite数据库:通过`.open <database>`命令打开数据库,`.databases`查看已连接的数据库,`.tables`查看数据库中的表,`.schema <table>`查看表结构,`.quit`退出SQLite shell。 在提供的压缩包子文件的文件...
通过组合使用`adb shell`和`sqlite3`命令可以访问Android设备上的SQLite数据库。例如: ```bash adb shell sqlite3 ``` ##### 13. 进入Shell命令行 使用`adb shell`命令可以直接进入Android设备的Shell命令行界面,...
SQLite3 是一个轻量级的关系型数据库管理系统,广泛应用于移动设备,尤其是Android系统。在Android 6.0(Marshmallow)版本中,SQLite3被用作内置的数据库引擎,用于应用程序存储结构化数据。这个“sqlite3 android...
在 Windows 环境下,通常下载 `sqlite-shell-win32-x86` 和 `sqlite-analyzer-win32-x86` 的 zip 包。前者是 SQLite 数据库引擎,后者是 SQLite 数据库分析器,主要用于分析数据库的状态等信息。 1. **创建数据库**...
在Android系统中,SQLite是一个内置的轻量级数据库引擎,用于存储应用程序的数据。SQLite3是其更新版本,提供了更高效和稳定的数据管理功能。对于Android 4.4(KitKat)和5.0(Lollipop)这两个较早的系统版本,安装...