Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – SQLITE Database not updating the TABLE

Posted on November 11, 2022 By

Solution 1 :

You need to mark your transaction as “clean” by calling db.setTransactionSuccessful() before calling db.endTransaction(). If you do not set your transaction as successful, your changes are immediately rolled back as soon as the transaction is ended (as it assumes there was an error).

For more information, see the SQLiteDatabase documentation here

Problem :

*TABLE NOT UPDATING*****HOW TO SOLVE THE PROBLEM

public String getElapsedTime(String session_id, String time) {
    db = this.getWritableDatabase();
    db.beginTransaction();
    db.setTransactionSuccessful();
    Log.d("CHINMAY", "Update in Sql get ElapsedTime " + session_id + "n" + time);
    ContentValues cv = new ContentValues();
    cv.put(ELAPSED_TIME, time);
    db.update(TABLE_SESSION_TEST, cv, "session_id=?", new String[]{session_id});
    db.endTransaction();
    return "Checking Update";
}

Comments

Comment posted by Chinmay Moharana

I didn’t understand how to clean.

Comment posted by Eric Bachhuber

db.update(TABLE_SESSION_TEST, cv, “session_id=?”, new String[]{session_id}); db.setTransactionSuccessful(); db.endTransaction();

Comment posted by Eric Bachhuber

db.update() returns an integer of how many rows have been updated. When that code runs, does db.update() return a 0 or a 1? If it’s a 0, check your data and query to make sure it’s correct.

Comment posted by Chinmay Moharana

i changed the code and return boolean value output is coming toast.message as true.But database i checked is not displaying.

Comment posted by Chinmay Moharana

Actually i tried the code is updated after some time. But when i move to next activity the value is not coming immediately

READ  [FIXED] java - Find Similarity between images (Bitmap) in Android
Powered by Inline Related Posts
Android Tags:android, android-sqlite, sql-update

Post navigation

Previous Post: [FIXED] android – how to change notification background color in nougat?
Next Post: [FIXED] android – How to make width ratio equal in XML GridView

Related Posts

[FIXED] Android Studio XML can’t outline imageview Android
[FIXED] android – Run the code in main threa after completeion of IO thread process kotlin coroutines Android
[FIXED] java – Can’t debug my Android library if the class was created with Kotlin Android
[FIXED] xml – Best way to save huge text in android Android
[FIXED] android – Very weird Retrofit response Android
[FIXED] android – Gradle not finding main method after changing project structure Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme