4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Android】inaccessible or not found っていうエラーを解決【データベース】

Posted at

今回のこと

ドットインストールのAndroidデータベース入門を進めていて、Android Studio内のターミナルを使っていた時の出来事です。
コマンドラインを使ってエミュレーターの中に入り、データベースの中身を操作する、ということをやりました。

その際のエラーが解決できたので、備忘録として書いていきます。

どう解決したか

もうすでにターミナルを使って、エミュレーターの中に入り、データベースのファイルがあるdatabasesディレクトリに移動していることを仮定して書いていきます。

まずは、lsでdatabasesディレクトリの中身を見ます。

generic_x86_arm:/data/data/パッケージ名/databases $ ls

実行結果
(db拡張子のファイル) (右と同じファイル)-journal

では、このファイルを、「sqlite3 ファイル名」でsqliteを起動しましょう。

generic_x86_arm:/data/data/パッケージ名/databases $ sqlite3 ファイル名

実行結果
sh: sqlite3: inaccessible or not found

あれ、ちがう結果になった。。。

原因を調べてみたところ、
「Google Playが実装された仮想デバイスは、root権限でログインできない」とのことでした。
参考サイト https://teratail.com/questions/186703

スクリーンショット (13).png

「Play ストア」欄に、三角マークがついていないものを新たにダウンロードなりして、それを起動しましょう。

起動出来たら、上のほうで省略しましたが「adb shell」からまた同じ手順でコマンドを入力していきましょう。
恐る恐る「sqlite3 ファイル名」と入力すると、

実行結果
SQLite version 3.28.0 2020-05-06 18:46:38
Enter ".help" for usage hints.
sqlite>

できたーーー!!
こんな感じの文が出てきたら起動が成功です。

結論

仮想デバイスがGoogle Playが実装されているかそうでないか、確認してみよう。

参考にさせていただきました

Androidデータベース入門 (全10回) - プログラミングならドットインストール(有料サービス)
Android - ADBコマンドをroot権限で使いたい|teratail

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?