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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:34:07+00:00 2026-06-03T02:34:07+00:00

i have created a database with the table name tbl_customer and tbl_product…i can view

  • 0

i have created a database with the table name tbl_customer and tbl_product…i can view the tbl_customer values but can’t see tbl_product values.. I use adb shell to confirm my insertion. Can any one plz help me to figure out the issue

private void addProFromDB() {
        // TODO Auto-generated method stub

        ArrayList<String> results = new ArrayList<String>();
        SQLiteDatabase sampleDB = null;

        try {
            list = (ListView)findViewById(android.R.id.list);
            list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
            sampleDB = this.openOrCreateDatabase(SAMPLE_DB_NAME, 1, null);
            sampleDB.execSQL("create table tbl_product("
                    + "pro_id integer PRIMARY KEY autoincrement,"
                    + "pro_name text," + "pro_price integer);");
            sampleDB.execSQL("INSERT INTO " + SAMPLE_TABLE_NAMES
                    + " Values ('1','Milk','60');");
            sampleDB.execSQL("INSERT INTO " + SAMPLE_TABLE_NAMES
                    + " Values ('2','Sugar','70');");
            sampleDB.execSQL("INSERT INTO " + SAMPLE_TABLE_NAMES
                    + " Values ('3','Oil','200');");
            Cursor c = sampleDB.query(SAMPLE_TABLE_NAMES, null, null, null, null, null,
                    null);
            char pro_nameColumnIndex = (char) c.getColumnIndexOrThrow("pro_name");
            int pro_priceColumnIndex = (int) c.getColumnIndexOrThrow("pro_price");

        } finally {
            if (sampleDB != null)
                sampleDB.execSQL("DELETE FROM " + SAMPLE_TABLE_NAMES);
            sampleDB.close();
        }
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_checked, new ArrayList()));

        new AddStringTask().execute();
    }

Also help me how i can get its primary key and display the selected value…
Best regards….

  • 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-03T02:34:09+00:00Added an answer on June 3, 2026 at 2:34 am

    First, it is a good idea to consider using the insert() method on SQLiteDatabase, instead of executing INSERT statements via execSQL(), particularly if you do not have much SQL experience.

    Second, normally, an INSERT statement lists the columns to be inserted into, which you are not doing. SQLite might support your syntax, but it makes for more fragile code.

    Third, with an autoincrement column, you do not assign your own values, as you are trying to do.

    Fourth, you are putting string values into integer columns. SQLite supports that, but not by actually converting the values to integers, but rather storing the strings themselves in the columns, which may not be what you want.

    Fifth, getColumnIndexOrThrow() returns an int, not a char.

    Sixth, you are deleting your data from the table milliseconds after inserting it, in your finally block, assuming that SAMPLE_TABLE_NAMES is set to tbl_product. If those values are not equal, then you are inserting into and querying from a table that does not exist.

    Seventh, your Cursor is dead as soon as you close() the database in your finally block.

    Some combination of those probably explains “the issue”.

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

Sidebar

Related Questions

I have created a new database table with the name 'table'. Now i'm trying
I have a database created with table name Accounts There are THREE columns. One
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
I have created a table on an Oracle 10g database with this structure :
Suppose I have following table in my database: Tbl_Persons: Id Country Name 1 Australia
I have successfully created a database table in android ( SQLite ). I am
I have created a database with MySQLdb. In database I have a table with
I have created a database with MySQLdb. In database I have a table with
I can't understand one thing. Suppose I already have these coded entities: [Table(Name =
I have created a mysql dump for only one table in my database. The

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.