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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:02:26+00:00 2026-05-29T06:02:26+00:00

I want get data in db to listview. but it have error I cannot

  • 0

I want get data in db to listview.

but it have error I cannot correct this problem.

Please help me

Thank!!

this my code


package com.BITS.DB;

import java.util.ArrayList;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;


public class ChoicePray extends ListActivity {

    AlertDialog dialog;
    EditText wordNameSearch;
    TextView typeShow;
    ImageView imageSearch;
    static Database db;
    static String database;
    String wordSearch = null;
    private int idWord;
    public String type="bits";

    public static Context context;
    private static final ArrayList<String> ListviewContent = new ArrayList<String>();
    private static final ArrayList<Integer> ListID = new ArrayList<Integer>();
    ListViewAdapter listAdap;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.choicepray);
        typeShow = (TextView) findViewById(R.id.groupshow);
        wordNameSearch = (EditText) findViewById(R.id.namePraySearch);
        imageSearch = (ImageView) findViewById(R.id.imageSearch);
        context = getBaseContext();
        db = new Database(this);
        showAllword();
        /*typeShow.setText("Bits");
        listAdap = new ListViewAdapter(this);
        listAdap.notifyDataSetChanged();
        setListAdapter(listAdap);
        SearchOnButton();*/
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
        }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) { 
    case R.id.add:{  
            Intent a = new Intent(getBaseContext(),Insert_Form.class);
            startActivity(a);
            break;
            }
    case R.id.bits:{
            type="bits";
            typeShow.setText("bits");
            showAllword();
            break;
            }
    case R.id.pray1:{
            type="pray1";
            typeShow.setText("pray1");
            showAllword();
            break;
            }
    case R.id.pray2:{
            type="2";
            typeShow.setText("pray2");
            showAllword();
            break;
            }

        } 
    return true; 
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
             AlertDialog dialog = new AlertDialog.Builder(this).create();
             dialog.setMessage("ARE YOU SURE EXIT ?");
             dialog.setButton(DialogInterface.BUTTON_POSITIVE, "YES",new DialogInterface.OnClickListener() { 
                 public void onClick(DialogInterface dialog, int which) {
                     {   finish();
                         android.os.Process.killProcess(android.os.Process.myPid());
                         System.exit(0);  
                        }
                     dialog.cancel();
                 } 
            });
            dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "NO", 
                     new DialogInterface.OnClickListener() {
                     public void onClick(DialogInterface dialog, int which) {
                         dialog.cancel();
                     } 
           });
            dialog.show();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    public void SearchOnButton(){
        imageSearch.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                wordSearch = wordNameSearch.getText().toString();
                ListID.clear();
                ListviewContent.clear();
                db = new Database(context);
                db.open();
                Cursor c = db.searchWord(wordSearch);
                if (c.moveToFirst()) {
                    do {
                        displayPray(c);
                    } while (c.moveToNext());
                }
                db.close();
                wordNameSearch.setText("");
                typeShow.setText("All");
                listAdap.notifyDataSetChanged();
                setListAdapter(listAdap);
            }

        });

    }

    public void ButtonAlertDialog(final int position){
         AlertDialog dialog = new AlertDialog.Builder(this).create();
         dialog.setMessage("ARE YOU SURE DELETE WORD ?");
         dialog.setButton(DialogInterface.BUTTON_POSITIVE, "YES",
                 new DialogInterface.OnClickListener() { 
                 public void onClick(DialogInterface dialog, int which) {
                     {
                            Log.v("Delete", "delete id" + ListID.get(position));
                            db.open();
                            boolean flag = db.deleteWord(ListID.get(position));
                            if (flag) {
                                Toast.makeText(context, "Delete Succeed.",
                                        Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(context, "Delete Failed",
                                        Toast.LENGTH_SHORT).show();
                            }
                            db.close();
                            showAllword(); 
                        }
                     dialog.cancel();
                 } 
       });
         dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "NO", 
                 new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int which) {
                     dialog.cancel();
                 } 
       });
         dialog.show();
    }

    public  void showAllword() {
        ListID.clear();
        ListviewContent.clear();
        db = new Database(context);
        db.open();
        Cursor c = db.getAllWord(type);
        if (c.moveToFirst()) {
            do {
                displayPray(c);
            } while (c.moveToNext());
        }
        db.close();
        listAdap = new ListViewAdapter(this);
        listAdap.notifyDataSetChanged();
        setListAdapter(listAdap);
    }

    public static void displayPray(Cursor c) {
        ListviewContent.add(c.getString(1));
        ListID.add(Integer.parseInt(c.getString(0)));
    }


    private class ListViewAdapter extends BaseAdapter {
        public LayoutInflater mInflater;

        public ListViewAdapter(Context context) {
            mInflater = LayoutInflater.from(context);
        }
        @Override
        public int getCount() {
            return ListviewContent.size();
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(final int position, View convertView, ViewGroup parent) {

            ListContent holder;
            View v = convertView;
            if (v == null || (v.getTag()==null)) {
                    v = mInflater.inflate(R.layout.list_item, null);
                    holder = new ListContent();
                    holder.text = (TextView) v.findViewById(R.id.TextView01);
                    v.setTag(holder);
            }
                    else {
                holder = (ListContent) v.getTag();
            }


            v.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    Intent ex = new Intent(getBaseContext(), Explan.class);
                    idWord = ListID.get(position);
                    ex.putExtra("idWord", idWord);
                    ex.putExtra("type", type);
                    startActivity(ex);
                }
            });

            holder.text.setText(ListviewContent.get(position)); 
            v.setOnLongClickListener(new OnLongClickListener(){
                 @Override
                 public boolean onLongClick(View v) {
                     ButtonAlertDialog(position);
                        return true;
                    }
                });
                return v;
        }

        private class ListContent {
            TextView text;  
        }
    }


}

and this database class

package com.BITS.DB;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class Database {

    public String Serach = null;
    public static final String KEY_ROWID = "_id";
    public static final String KEY_NAME = "name";
    public static final String KEY_WORD = "word";
    public static final String KEY_TYPE = "type";
    public static final String KEY_EXPLANTION = "Explanation";
    public static final String TAG = "DatabasePray";
    public static final String DATABASE_NAME = "BITSonMobiles";
    public static final String DATABASE_TABLE = "bits_table";
    public static final int DATABASE_VERSION = 1;

    private static final String DATABASE_CREATE = "create table pray"
            + "(_id integer primary key autoincrement," + "word char(40)NOT NULL,"
            + "Explanation text NOT NULL);";

    private Context context = null;
    private DatabaseHelper DBHelper;
    private SQLiteDatabase db;



    public Database(Context ctx) {
        this.context = ctx;
        DBHelper = new DatabaseHelper(context);
    }

    public Database open() throws SQLException {
        db = DBHelper.getWritableDatabase();
        return this;
    }

    public void close() {
        DBHelper.close();
    }

    public long insertWord(String name, String word, String type, String Explanation) {
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_NAME, name);
        initialValues.put(KEY_WORD, word);
        initialValues.put(KEY_TYPE, type);
        initialValues.put(KEY_EXPLANTION, Explanation);
        return db.replace(DATABASE_TABLE, null, initialValues);
    }

    public boolean deleteWord(long rowId) {
        return db.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0;

    }

    public boolean updateWord(long rowId, String name, String type, String word, String Explanation) {
        ContentValues args = new ContentValues();
        args.put(KEY_NAME, name);
        args.put(KEY_WORD, word);
        args.put(KEY_TYPE, type);
        args.put(KEY_EXPLANTION, Explanation);
        return db.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) > 0;
    }

    public Cursor getAllWord(String type) {
        return db.query(DATABASE_TABLE, new String[] {
                KEY_ROWID,
                KEY_NAME,
                KEY_WORD,
                KEY_TYPE,
                KEY_EXPLANTION }, 
                KEY_TYPE + "=" + type , 
                null, 
                null, 
                null, 
                KEY_WORD);
    }

    public Cursor searchWord(String Wordcom) throws SQLException {

        Cursor mCursor = db.query(true, DATABASE_TABLE, new String[] {
                KEY_ROWID,
                KEY_NAME,
                KEY_WORD,
                KEY_TYPE,
                KEY_EXPLANTION },
                KEY_WORD + "=" + Wordcom,
                null, 
                null, 
                null, 
                KEY_WORD, 
                null);
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        return mCursor;
    }


    public Cursor getWord(long rowId) throws SQLException {

        Cursor mCursor = db.query(true, DATABASE_TABLE, new String[] {
                KEY_ROWID,
                KEY_NAME,
                KEY_WORD,
                KEY_TYPE,
                KEY_EXPLANTION },
                KEY_ROWID + "=" + rowId,
                null, 
                null, 
                null, 
                null, 
                null);
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        return mCursor;
    }

    private static class DatabaseHelper extends SQLiteOpenHelper {
        DatabaseHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL(DATABASE_CREATE);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.w(TAG, "Upgrading database from version" + oldVersion + " to "
                    + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS titles");
            onCreate(db);
        }
    }

}

And here is the error messages from the LogCat:

ERROR/AndroidRuntime(274): FATAL EXCEPTION: main

ERROR/AndroidRuntime(274): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.BITS.DB/com.BITS.DB.ChoicePray}: android.database.sqlite.SQLiteException: no such table: bits_table: , while compiling: SELECT _id, name, word, type, Explanation FROM bits_table WHERE type=bits ORDER BY word

ERROR/AndroidRuntime(274):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)

ERROR/AndroidRuntime(274):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)

ERROR/AndroidRuntime(274):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)

ERROR/AndroidRuntime(274):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)

ERROR/AndroidRuntime(274):     at android.os.Handler.dispatchMessage(Handler.java:99)

ERROR/AndroidRuntime(274):     at android.os.Looper.loop(Looper.java:123)

ERROR/AndroidRuntime(274):     at android.app.ActivityThread.main(ActivityThread.java:4627)

ERROR/AndroidRuntime(274):     at java.lang.reflect.Method.invokeNative(Native Method)

ERROR/AndroidRuntime(274):     at java.lang.reflect.Method.invoke(Method.java:521)

ERROR/AndroidRuntime(274):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

ERROR/AndroidRuntime(274):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

ERROR/AndroidRuntime(274):     at dalvik.system.NativeStart.main(Native Method)

ERROR/AndroidRuntime(274): Caused by: android.database.sqlite.SQLiteException: no such table: bits_table: , while compiling: SELECT _id, name, word, type, Explanation FROM bits_table WHERE type=bits ORDER BY word

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)

ERROR/AndroidRuntime(274):     at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1264)

ERROR/AndroidRuntime(274):     at com.BITS.DB.Database.getAllWord(Database.java:72)

ERROR/AndroidRuntime(274):     at com.BITS.DB.ChoicePray.showAllword(ChoicePray.java:188)

ERROR/AndroidRuntime(274):     at com.BITS.DB.ChoicePray.onCreate(ChoicePray.java:53)

ERROR/AndroidRuntime(274):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

ERROR/AndroidRuntime(274):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

ERROR/AndroidRuntime(274):     ... 11 more

So, can anybody help to get through this? Thank you in advance !

  • 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-29T06:02:27+00:00Added an answer on May 29, 2026 at 6:02 am

    You have created table a pray and DATABASE_TABLE = "bits_table" does not exist

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

Sidebar

Related Questions

I have one problem , I want to get some data from XML file
Now I find ploblem again. I want get data in db to listview. but
I want to get the data every day within one year backward but I
I have image data and i want to get a sub image of that
I have a listview that's populated by rows that get their data from a
this seemed simple at first but I can't get it to work. I have
What method do you use when you want to get performance data about specific
I am using http://lite.facebook.com And i want to get some data from my account.
I want to get at the item that is being data bound, during the
What I want to do is get the data from two different tables (table1

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.