SQLite Installer for RootでSQLのモバイル学習環境を入手

どのバージョンからかは不明だが、少なくともASUS MeMO Pad HD7のAndroid 4.2.2には存在しないsqlite3をインストールして、SQLのモバイル学習環境を入手しよう。

インストール手順

1. Android端末にSuperSUをインストール

名前の「for root」が示すように、インストールに必要なroot権限を得るためにSuperSUをインストールする。

2. SQLite Installer for Rootでsqlite3をインストール

1) Google PlayからSQLite Installer for Rootをインストールし、実行すると以下の画面が表示されるので、「Install」ボタンをタップする。

3) 左上のバージョンをタップすると、インストール可能なsqlite3のバージョンが一覧できる。

4) 最新のバージョン(3.7.6)を選択して「Go」ボタンをタップする。

5) 進捗画面が表示される。

6) root権限の許可画面が表示されるので「許可」ボタンをタップする。

7) sqlite3のインストールが完了する。


アプリ内課金について

Google Playでアプリ内課金があると表示されていたので、インストールするのに躊躇したが、メイン画面の「Remove ADs」ボタンで広告表示を消すために必要なだけで、sqlite3をインストールするのには何の障害もなかった。

実際にsqlite3を使ってみる

Android端末のUSBデバッグをオン(詳細は以前の記事を参照)にし、PCに接続してからコマンドプロンプトを開いて、以下のコマンドを実行する。

> adb shell
shell@android:/ $ cd sdcard
cd sdcard
shell@android:/sdcard $ sqlite3 hoge.sqlite
sqlite3 hoge.sqlite
SQLite version 3.7.16 2013-03-18 11:39:23 [www.ptsoft.org] [www.ptdave.com]
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table fruit (
create table fruit (
   ...> name varchar(20),
name varchar(20),
   ...> price int
price int
   ...> );
);
sqlite> insert into fruit (name, price) values ("apple", 100);
insert into fruit (name, price) values ("apple", 100);
sqlite> insert into fruit (name, price) values ("orange", 50);
insert into fruit (name, price) values ("orange", 50);
sqlite> insert into fruit (name, price) values ("ayashii", 9999);
insert into fruit (name, price) values ("ayashii", 9999);
sqlite> select * from fruit;
select * from fruit;
apple|100
orange|50
ayashii|9999
sqlite> .header on
.header on
sqlite> .mode column
.mode column
sqlite> select * from fruit;
select * from fruit;
name        price
----------  ----------
apple       100
orange      50
ayashii     9999
sqlite> .databases
.databases
seq  name             file

---  ---------------  ----------------------------------------------------------

0    main             /mnt/shell/emulated/0/hoge.sqlite

sqlite> .q
.q
shell@android:/sdcard $ exit
exit

PCからadbで操作してもモバイルの目的を果たしていないが、Terminal IDE以前の記事を参照)で使用すれば目的は果たせる。