0

Whenever I run the following line

  adb -d shell "run-as com.package.name ls /data/user/0/com.package.name/databases/" 

I get the following error

 /data/user/0/com.package.name/databases/ no such file or directory

This is how I'm creating the database

   public SQLiteHelper(Context context, String DatabaseName) {
    super(context, DatabaseName+".db", null, 1);

    this.context      = context;
    this.DatabaseName = DatabaseName+".db";
    Log.d(TAG, "DB: " + DatabaseName);
    Log.d(TAG, "Path: " + context.getDatabasePath(this.DatabaseName).toString());


}

The Log cat however displays the following

 Path: /data/user/0/com.package.name/databases/test1.db

Signaling that the database has been created. Why is the command prompt telling me no such file or directory exists?

Hours ago I entered the line

   adb shell pm clear com.package.name

As I wanted to delete the previous databases that I found on the device. But when I started to have problems I simply uninstalled using

  adb uninstall com.package.name

However, I'm still experiencing problems. My overall main goal is to simply view the contents of my databases for development purposes. I currently have a Nexus 5 (Android Version 6.0.1 unrooted phone) connected to a PC.

Does anyone have an idea on what the problem might be?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • 1
    You might not have permission as the adb shell to enter the directory in order to `ls` it, regardless of the existence of the actual file – OneCricketeer May 24 '17 at 01:46
  • @cricket_007 The tool you recommended is great. However, I still can't see my databases Under WebSQL. I have the following in my onCreate function in the Application class: Stetho.initializeWithDefaults(this); It seems other aspects of the framework does work as I can see my shared preferences under local storage. –  May 24 '17 at 06:24
  • Did you setup the application class within the manifest? I've not used Stetho, so I don't exactly know how it works – OneCricketeer May 24 '17 at 06:27
  • Actually never mind. The problem was I wasn't writing anything to the database. So a database and table were not created. Thanks again for recommending the tool. –  May 24 '17 at 06:39

1 Answers1

0

you can see how to create database in android studio in this link,

then for pulling the database out of your application:

1: run your application in your emulator 2: in android studio top menu open Tools --> Android --> Android Device Monitor 3: in the right section of the Android Device Monitor you can find the file explorer with out using any shell script . 4: in data folder find your package name then pull out the db