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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:48:13+00:00 2026-05-26T10:48:13+00:00

Can anyone look at my attached code and tell me why I am not

  • 0

Can anyone look at my attached code and tell me why I am not inserting or selecting from the database any values. I can’t even tell which I am not doing because I am not getting any errors. All I know is that when I run the select query the cursor contains nothing.

Thanks

SQLiteDatabase db = new DatabseHelper(this).getWritableDatabase();
          //  db.execSQL(mDATABASE_CREATE);
            String id = "1";
            String feedback = "this is some feedback";
            String expiredAt = "12:00";
            String priority = "1";
            String read = "false";
            String sql =   "INSERT INTO feedbackTable (_id, feedback, expiredAt, priority, read) VALUES (\""+id+"\", \""+feedback+"\", \""+expiredAt+"\", \""+priority+"\", \""+read+"\")"; 
            db.rawQuery(sql, null);
            Cursor result = db.rawQuery("SELECT * FROM feedbackTable", null);
            result.moveToFirst();

            String rfeedback="";
            while(!result.isAfterLast()){
                rfeedback=result.getString(1);
            }

        Log.e("returned feedback", "inserted feedback "+rfeedback);
            db.close();

Second issue after changing above code:

SQLiteDatabase db = new DatabseHelper(this).getWritableDatabase();
            String id = "1";
            String feedback = "this is some feedback";
            String expiredAt = "12:00";
            String priority = "1";
            String read = "false";
            String sql =   "INSERT INTO feedbackTable (_id, feedback, expiredAt, priority, read) VALUES (\""+id+"\", \""+feedback+"\", \""+expiredAt+"\", \""+priority+"\", \""+read+"\");"; 


            ContentValues values = new ContentValues(5);
            values.put("_id", "1");
            values.put("feedback", "some feedback");
            values.put("expiredAt", "12:00");
            values.put("priority", "1");
            values.put("read", "false");
            db.insert("feedbackTable", "_id", values);
            Cursor result = db.rawQuery("SELECT * FROM feedbackTable", null);
            //db.execSQL(sql);
            //insert(feedbackTable, nullColumnHack, values)
            //.rawQuery(sql, null);
            result.moveToFirst();

            String rfeedback="";
            while(!result.isAfterLast()){
                rfeedback=result.getString(1);
            }

            Log.e("returned feedback", "inserted feedback "+rfeedback);
            db.close();

Using both execSQL and db.insert my application just hangs waiting for a response. I never reach the Log.e above and because this action takes place in the oncreate method before the screen is drawn, I see only a blank screen. Any idea why?

  • 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-26T10:48:14+00:00Added an answer on May 26, 2026 at 10:48 am

    I suspect that you need to advance your cursor. It would appear that your code is stuck in while (!result.isAfterLast()). Unless you result.moveToNext() (or in some other fashion advance the cursor) it will never be after last and the while statement will loop indefinitely. In fact if you expect only one row you could just eliminate the while loop entirely.

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

Sidebar

Related Questions

I wonder is anyone can look at this code and tell me why calling
Can anyone have a look at the php code I wrote. I want to
Can anyone tell me the best way to ensure asp.net sites look the same
I've been look at this for the last hour or so. Can anyone tell
Can anyone recommend a free grid/graphing component for C#/.NET? I'm having a look at
Can anyone tell me how to hide the header in DevExpress gridcontrol..?? I'm using
Can anyone guide me how to register a user from mobile device (rest API)
Can anyone shed some light on this for me: http://67.212.188.229/fcf/index.html <- Please look at
Tried to look for that and didn't find an answer. Can anyone help? Thanks.
I am having trouble implementing the bootstrap carousel. Can anyone look at the following

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.