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 8591631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:34:15+00:00 2026-06-11T23:34:15+00:00

Assume that I get a Cursor by db.query() . Then I modify a field

  • 0

Assume that I get a Cursor by db.query().
Then I modify a field in a row by db.update(),and this row is included by Cursor queried before.
Data in this Cursor will change or not?

like this:

Cursor cur = db.query("[some parameter can get row 0]"); 
cur.moveToFirst; 
int a = cur.getInt(0);
db.update("[some parameter can modify row 0 col 0]");
int b = cur.getInt(0);

Is (a==b) true or false ?

====== edited 2012.10.1 =========
I am not a pro-programmer,and too busy to code in these days.
If I make you unhappy ,I am very sorry.
Finally , I get a holiday of a week, haha .

I do some coding like this:

SQLiteOpenHelper h = null;
SQLiteDatabase db = null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    h=new SQLiteOpenHelper(this, "test.db", null,1){

        @Override
        public void onCreate(SQLiteDatabase arg0) {
            // TODO Auto-generated method stub
            arg0.execSQL("CREATE TABLE t1 (_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT )");
            arg0.execSQL("INSERT INTO t1 (name) VALUES ('name_wrong')");
        }

        @Override
        public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
            // TODO Auto-generated method stub

        }};

    db=h.getWritableDatabase();
    Cursor cur =  db.query("t1", null, null, null, null, null, null);
    cur.moveToFirst();
    String s1=cur.getString(1);

    db.execSQL("UPDATE t1 SET name = 'name_right'");

    String s2=cur.getString(1);
    Log.d("","s1 = "+s1);
    Log.d("","s2 = "+s2);
    Log.d("","s1 == s2 is "+s1.equals(s2));
    Log.d("","requery...");
    cur =  db.query("t1", null, null, null, null, null, null);
    cur.moveToFirst();
    s2=cur.getString(1);
    Log.d("","s1 = "+s1);
    Log.d("","s2 = "+s2);
    Log.d("","s1 == s2 is "+s1.equals(s2));
}  

And logcat say that:

10-01 03:11:28.356: D/(1514): s1 = name_wrong
10-01 03:11:28.356: D/(1514): s2 = name_wrong
10-01 03:11:28.356: D/(1514): s1 == s2 is true
10-01 03:11:28.356: D/(1514): requery...
10-01 03:11:28.356: D/(1514): s1 = name_wrong
10-01 03:11:28.356: D/(1514): s2 = name_right
10-01 03:11:28.356: D/(1514): s1 == s2 is false

So I think I get the answer
Thank you all guys.

  • 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-06-11T23:34:16+00:00Added an answer on June 11, 2026 at 11:34 pm
    1. you don’t see any changes except if you re-query.
    2. cursors are not live. that is, the moment you have a cursor loaded, it has nothing to do with the database anymore. it is just a data structure (like an array).

    Basically

    Is (a==b) true or false ?

    false

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

Sidebar

Related Questions

Assume that there's no problem with my header file and some included library. I'm
Assume that I have 2 .php files : index.php and ajax.php This is index.php:
Assume that I have login to system using PHP + MySQL, then, after I
I am looking for a nice simple LINQ query that can get an item
Assume that we have class public class RMenuItem { public List<RMenuItem> ChildrenItems { get;
i need to write simple application that get class name ( assume that the
I'm trying to use iBatis to insert some data that get sent by a
I need to create WebMethod that will get some data from db and return
Assume that we have two sets: A=(a_1,a_2,...,a_m) and B=(b_1,b_2,...,a_n) (Not necessarily of same size).
Assume that i have created a client TCP Socket in Activity A. I want

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.