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

  • Home
  • SEARCH
  • 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 6675885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:55:00+00:00 2026-05-26T03:55:00+00:00

I want to know how to get the value of the selected rawquery Cursor

  • 0

I want to know how to get the value of the selected rawquery

Cursor data = dbObject.rawQuery("SELECT _id FROM COMAPNY WHERE _id LIKE ?",
                 new String[] { "%" + val2 + "%" });

as a sqlite database input. i want to select the number (val2) and then put that number to handle.KEY_ID2 column. is it possible and how to do it?

FULL CODE

DataBase

package test.com;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class handle extends SQLiteOpenHelper {

     public static final String DB_NAME = "SHARE_DB";
     public static final String DB_COMPANYTABLE = "COMAPNY";
     public static final String DB_SHARETABLE = "SHARE";
     public static final int DB_VERSION = 1;
     public static final String KEY_ID = "_id";
     public static final String KEY_ID2 = "_id2";
     public static final String ROW_ID = "_id";
     public static final String COMPANY_NAME = "Name";
     public static final String COMPANY_SHAREP = "Price";
     public static final String COMPANY_SHAREV = "Volume";

    public handle(Context context, String name, CursorFactory factory,
            int version) {
        super(context, name, factory, version);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL(SCRIPT_CREATE_DATABASE);
        db.execSQL(SCRIPT_CREATE_DATABASE2);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub
        db.execSQL("DROP TABLE IF EXISTS " + DB_COMPANYTABLE);
        db.execSQL("DROP TABLE IF EXISTS " + DB_SHARETABLE);
        onCreate(db);
    }

    private static final String SCRIPT_CREATE_DATABASE = "create table " + DB_COMPANYTABLE + " (" 
                +KEY_ID + " integer primary key autoincrement, " 
                + COMPANY_NAME + " text not null);";

private static final String SCRIPT_CREATE_DATABASE2 = "create table " + DB_SHARETABLE + " (" 
                + ROW_ID + " integer primary key autoincrement, " 
                + KEY_ID2 + " integer, " 
                + COMPANY_SHAREP + " text not null, " 
                + COMPANY_SHAREV + " text not null);";
}

Activity1

private ListView.OnItemClickListener listContentOnItemClickListener
   = new ListView.OnItemClickListener(){

  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position,
    long id) {
Company comid = new Company();
      Cursor cursor = (Cursor) parent.getItemAtPosition(position);
      int item_id = cursor.getInt(cursor.getColumnIndex(handle.KEY_ID));

               String item = String.valueOf(item_id);

           comid.setCompanyID(item);    

           startActivity(new Intent("android.intent.action.next"));
     }};

Activity2

    Company obj1 = new Company();
    String val1 = obj1.getCompanyID();

protected void saveRecord() {
    // TODO Auto-generated method stub
    conValue.put(handle.COMPANY_SHAREP, two.getText().toString());
    conValue.put(handle.COMPANY_SHAREV, three.getText().toString());
    conValue.put(handle.KEY_ID2, four.getText().toString());
    dbObject.insert(handle.DB_SHARETABLE, null, conValue);
}

As for now i have to enter the KEY_ID2, but what i want is.. when the user click on the ACTIVITY1 list… it send the row id as “val1” & i want that value to be entered on ACTIVITY2 button click

  • 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-26T03:55:01+00:00Added an answer on May 26, 2026 at 3:55 am

    There is no direct way of doing it. You would need to:

    1. Make the query to your Database to get the cursor,
    2. Move the Cursor to the first element,
    3. Get the String/Int/Whatever from the cursor,
    4. Insert this value by using an insert.

    But I see a very more basic problem here: Your database-layout. It should never rely on redundantly saved data!

    Please have a look at your Database and check if you can use a relation to make the connection between the two values.

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

Sidebar

Related Questions

I want to know how can I get the value of the selected option
i want know if is possible, to get a specific element value of a
I want to know how to get the cursor position on Windows in c++,
I want to know how to get mp3 file details like artist, title, album
I want to know how to get a specific row from a table in
I want to know how we can get record count using reference cursor in
I know how to get the selected value in an html dropdown menu using
Does anyone know how to get the cells value of the selected row of
I know how to get value/text of the selected item in a drop down:
I want to know how to get client IP address using jQuery? Is it

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.