Running Update on Android SQLiteDatabase without DatabaseHelper
<p>Trying to simple update a row in an SQLiteDatabase Database. I can insert records fine with:</p>

<pre><code>myDB.execSQL("INSERT INTO " + table + " (Date, Urine, Def, Flat, Snez, Mus)" + " VALUES     ('" + dat + "', " + uri + ", " + def + ", " + fl + ", " + sn + ", " + mu + ");");
</code></pre>

<p>But when i try to update a row with:</p>

<pre><code>myDB.execSQL("UPDATE " + TableMain + " SET " + field+ "=" + number + "WHERE Date = "+ DateMaker(today)+";");
</code></pre>

<p>I get a "Database Not Open" error in LogCat. So i try to open teh datbase with:</p>

<pre><code>SQLiteDatabase db=myDB.getWritableDatabase();
</code></pre>

<p>But im told by eclipse that getWritableDatabase() is undefined, so i tried:</p>

<pre><code>myDB.openDatabase("myDB", null, MODE_PRIVATE);
</code></pre>

<p>But then im greeted with the error "Unable to open Databse File". So i changed the path to data/data/com.BodyTracker/database so..:</p>

<pre><code>myDB.openDatabase("data/data/com.BodyTracker/database", null, MODE_PRIVATE);
</code></pre>

<p>And i once again get unable to open database error. I dont know why it cant open it, it can write to and read from the datbase, it just wont update. FYI, this is all happening in my main activity, which extends TabActivity, not SQLiteDatabase. I'm not using DatabaseHelper, im too much of a newb and its too complicated for my simple needs (reading in and out 6 values, and updating them).</p>

<p>Where i create the database:</p>

<pre><code>   myDB = this.openOrCreateDatabase("DatabaseName", MODE_PRIVATE, null);
     /* Create a Table in the Database. */
     myDB.execSQL("CREATE TABLE IF NOT EXISTS "
       + TableMain
       + " (Date VARCHAR, Urine INT(3), Def INT(3), Flat INT(3), Snez INT(3), Mus INT(3));");
</code></pre>

<p>My Update Code:</p>

<pre><code>public int UpdateDB(String field, int number)
{
 //SQLiteDatabase db=myDB.getWritableDatabase();
 ContentValues cv=new ContentValues();
 cv.put("Urine", number);
 cv.put("Def", number);
 cv.put("Flat", number);
 cv.put("Snez", number);
 cv.put("Mus", number);
 cv.put("Date", DateMaker(today));

 myDB.openDatabase("data/data/com.BodyTracker/database", null, MODE_PRIVATE);


// myDB.rawQuery("UPDATE " + TableMain + " SET " + field+ "=" + number + "WHERE Date =? ", new String[]{DateMaker(today)});
// myDB.execSQL("UPDATE " + TableMain + " SET " + field+ "=" + number + "WHERE Date = "+ DateMaker(today)+";");
 return myDB.update(TableMain, cv, "Date=?", new String[]{DateMaker(today)});   

}
</code></pre>

<p>Please ask for other info, this is my first question so not 100% what exactly to give.</p>
