Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7444611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:32:58+00:00 2026-05-29T11:32:58+00:00

Trying to simple update a row in an SQLiteDatabase Database. I can insert records

  • 0

Trying to simple update a row in an SQLiteDatabase Database. I can insert records fine with:

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

But when I try to update a row with:

myDB.execSQL("UPDATE " + TableMain + " SET " + field+ "=" + number + "WHERE Date = "+ DateMaker(today)+";");

I get a "Database Not Open" error in LogCat. So I try to open the database with:

SQLiteDatabase db=myDB.getWritableDatabase();

But I’m told by eclipse that getWritableDatabase() is undefined, so I tried:

myDB.openDatabase("myDB", null, MODE_PRIVATE);

But then I’m greeted with the error "Unable to open Database File". So I changed the path to data/data/com.BodyTracker/database so..:

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

And I once again get unable to open database error. I don’t know why it can’t open it, it can write to and read from the database, it just won’t update. This is all happening in my main activity, which extends TabActivity, not SQLiteDatabase. I’m not using DatabaseHelper, I’m new to this and it’s too complicated for my simple needs (reading in and out 6 values, and updating them).

Where I create the database:

   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));");

My Update 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)});   
 
}

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:32:59+00:00Added an answer on May 29, 2026 at 11:32 am

    Try update command

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do a simple update, but can't figure out somthing. I have
I'm creating a simple back-end app through which the user can create/update/delete database rows
I'm trying to update a table in Oracle and I'm running into some difficulty.
Am trying to construct a simple update query in my model class Model_DbTable_Account extends
I'm trying to do a simple update. I've done this kind of thing thousands
I am trying to write a simple Javascript snippet into a Codeigniter link. I
I am trying to set every row's CheckColor to Blue in the table tblCheckbook
I am trying to update an Access database with a vb script by putting
I'm trying to update an HTML table with new data pulled in via json
I'm trying to update some rows in a table based on two other columns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.