title: Why is my SQLite Database not created/saved to disk?
body: <p>I created code to create a SQLite database based on the article <a href="http://www.techotopia.com/index.php/An_Android_SQLite_Database_Tutorial" rel="nofollow noreferrer">here</a>.</p>
  
  <p>The most pertinent code is:</p>
  
  <pre><code>private static final int DATABASE_VERSION = 1;
  private static final String DATABASE_NAME = "Platypus.db";
  private static final String TABLE_VENDORS = "vendors";
  
  public static final String COLUMN_ID = "_id";
  public static final String COLUMN_VENDORID = "vendorId";
  public static final String COLUMN_COMPANYNAME = "companyName";
  
  public SQLiteHandlerVendors(Context context, String vendor,
                              SQLiteDatabase.CursorFactory factory, int company) {
      super(context, DATABASE_NAME, factory, DATABASE_VERSION);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
      String CREATE_VENDORS_TABLE = "CREATE TABLE " +
              TABLE_VENDORS + "("
              + COLUMN_ID + " INTEGER PRIMARY KEY," + COLUMN_VENDORID
              + " TEXT," + COLUMN_COMPANYNAME + " TEXT" + ")";
      db.execSQL(CREATE_VENDORS_TABLE);
  }
  
  public void addVendor(Vendor vendor) {
      ContentValues values = new ContentValues();
      values.put(COLUMN_VENDORID, vendor.getVendorId());
      values.put(COLUMN_COMPANYNAME, vendor.getCompanyName());
  
      SQLiteDatabase db = this.getWritableDatabase();
  
      db.insert(TABLE_VENDORS, null, values);
      db.close();
  }
  </code></pre>
  
  <p>Yet, although the insertions of data seem to be working -- the calls to <code>addVendor()</code> run without any exception being thrown with the following code:</p>
  
  <pre><code>protected void onPostExecute(String result) {
      try {
          JSONArray jsonArr = new JSONArray(result);
          for (int i = 0; i &lt; jsonArr.length(); i++) {
              JSONObject jsonObj = jsonArr.getJSONObject(i);
              String vendorId = jsonObj.getString("vendorId");
              String companyName = jsonObj.getString("companyName");
              Log.i("vendorId", vendorId);
              Log.i("companyName", companyName);
              // Prepare for writing to db
              Vendor vend = new Vendor();
              vend.setVendorId(vendorId);
              vend.setCompanyName(companyName);
              SQLiteHandlerVendors sqliteHandler = new SQLiteHandlerVendors(MainActivity.this, null, null, 1);
              sqliteHandler.addVendor(vend);
          }
      } catch (JSONException j) {
          System.out.println(j.getMessage());
          Log.i("jsonEx", j.getMessage());
      }
      Log.i("GetVendorsTask.FromOnPostExecute", result);
  }
  </code></pre>
  
  <p>I cannot locate the <em>Platypus.db</em> file that should have been created.</p>
  
  <p><a href="http://www.vogella.com/tutorials/AndroidSQLite/article.html" rel="nofollow noreferrer">This article</a> says, "<em>If your application creates a database, this database is by default saved in the directory DATA/data/APP_NAME/databases/FILENAME</em>."</p>
  
  <p>A global search for "Platypus.DB" on my hard drive turns up nothing. Is the database created not being persisted, or is there some other reason why I'm not finding it?</p>
  
  <p>I tried to find it by adding this code:</p>
  
  <pre><code>Log.i("Data Dir", Environment.getDataDirectory().toString());
  </code></pre>
  
  <p>...and when LogCat gives me is:</p>
  
  <pre><code>04-07 12:36:47.133    1089-1089/platypus.app I/Data Dir﹕ /data
  </code></pre>
  
  <p>There is no "data" folder in <em>C:\Users\clay\AndroidStudioProjects\Platypus</em>, nor is there one in the root of my hard drive (*C:*).</p>
  
  <p>Can the data dir/file only be viewed in some virtual space, in a file system for the emulator or so? If so, how can I actually access the emulator's file system to view this data?</p>
  
  <h2>UPDATE</h2>
  
  <p>Okay, I opened up this view, and navigated to data/data/hhs (the app's name is really "hhs" not "platypus"):</p>
  
  <p><img src="https://i.stack.imgur.com/73DIN.png" alt="enter image description here"></p>
  
  <p>...but still do not see HHS.DB (I see no "databases" folder below all that)...</p>
  
  <h2>UPDATE 2</h2>
  
  <p>If I select the "&lt;=" button ("Pull a file from the device") with the file with the size of 16384 highlighted, it <em>does</em> open the "Get Device File" dialog with a filename of "HHS.DB" (just what I was hoping to find).</p>
  
  <p>But, why is its path "data\data\hhs\unnamed folder\unnamed file" instead of "data\data\hhs\databases\HHS.DB"?</p>
  
  <p>The other file (size 8720) is HHS.db-journal</p>
  
  <h2>UPDATE 3</h2>
  
  <p>After saving those files to my hard drive and downloading <a href="http://sourceforge.net/projects/sqlitebrowser/" rel="nofollow noreferrer">SQLite Data Browser</a>, I'm able to verify that the records actually were written to the table:</p>
  
  <p><img src="https://i.stack.imgur.com/z5BC5.png" alt="enter image description here"></p>
  
  <p>SQLite Data Browser is a great tool for just such a need!</p>
  
  <h2>UPDATE 4</h2>
  
  <p>I don't know what changed/how it changed, but it's now working as it should:</p>
  
  <p><img src="https://i.stack.imgur.com/xttDL.png" alt="enter image description here"></p>