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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:44:26+00:00 2026-06-06T23:44:26+00:00

I made a table in SQLite browser and import the data in assets folder

  • 0

I made a table in SQLite browser and import the data in assets folder in adnroid,now i am getting an error no such table, in my logcat,this is my code…


public class CardDatabase {

    private static final String TB_CARD_ID="CARD_ID";
    private static final String TB_CARD_QUESTION="CARD_QUESTION";
    private static final String TB_CARD_ANSWER="CARD_ANSWER";

    public static final String TABLE_CREATE =
            "CREATE TABLE TB_CARDS (" + " CARD_ID INTEGER PRIMARY KEY, "+
                    " CARD_QUESTION VARCHAR ," +
            " CARD_ANSWER VARCHAR);"

            ;

    private final Context context;
    public static MydataBasehelper DBHelper;
    public static SQLiteDatabase db;

    public CardDatabase(Context ctx)
    {Log.e("problem","here2");
            Log.e("info","database called");
            this.context = ctx;
            DBHelper = new MydataBasehelper(context);

            try 
            {
                DBHelper.createDataBase();
            } 
            catch (IOException ioe)
           {
                 throw new Error("Unable to create database");
     }

        try {

            DBHelper.openDataBase();

            }
        catch(SQLException sqle)
        {

            throw sqle;
        }



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

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



    public static  void insert(

                    String CARD_ID,
                    String CARD_QUESTION,
                    String CARD_ANSWER


    ){
                            ContentValues initialValues = new ContentValues();
            initialValues.put(TB_CARD_ID,CARD_ID);
            initialValues.put(TB_CARD_QUESTION,CARD_QUESTION);
            initialValues.put(TB_CARD_ANSWER,CARD_ANSWER);





            try{
            Log.e("HERE IT IS", CARD_ID);


            }catch (Exception e) {
               Log.e("here","null");
                }

            db.insert("TB_CARDS", null, initialValues);

    }
    public static void truncate(){
            db.execSQL("DELETE FROM TB_CARDS");
    }
    public static void deletetable(){db.execSQL("DROP TABLE IF EXISTS TB_CARDS");}
    public static void createtable(){db.execSQL(TABLE_CREATE);}

    public Cursor getrecord( String CARD_ID){
            Log.e("we are","here");
            Cursor mCursor= db.query("TB_CARDS", new String[] {
                            TB_CARD_ID,
                            TB_CARD_QUESTION,
                            TB_CARD_ANSWER,


            },TB_CARD_ID  + "=" +"'"+ CARD_ID+ "'"
            ,null,null,null,null,null);
            if (mCursor != null) {
                    mCursor.moveToFirst();
            }
            return mCursor;
    }
    Cursor cur;
    public Cursor selectAll(){

        try{
        String query="SELECT * FROM TB_CARDS";
        System.out.println(query);
        cur= db.rawQuery(query,null);
        cur.moveToFirst();
        }

        catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            System.out.println("problem");
        }
        return cur;

    }

AND this is mydatabasehelper..

    public class MydataBasehelper extends SQLiteOpenHelper 
{
    private static final String TAG = "info";

      private static final String DB_NAME = "flipdata1";
      private static final String DB_PATH="data/data/cue.flip/databases/";
      private SQLiteDatabase myDataBase; 
    private static final int DATABASE_VERSION =1332;

      private  Context mycontext;

    public MydataBasehelper(Context context) 

    {


        super(context, DB_NAME, null, DATABASE_VERSION);
        Log.e("info","dataHelper");
    }

    @Override
    public void onCreate(SQLiteDatabase db) 
    {



    //  Log.e("aashish","table create was called");

        //db.execSQL(CardDatabase.TABLE_CREATE);

        //db.execSQL(Question_database.TABLE_CREATE);
        //db.execSQL(Answers_Database.TABLE_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 " + "TB_CARDS");




        //db.execSQL("DROP TABLE IF EXISTS " + Question_database.DATABASE_TABLE);
        //db.execSQL("DROP TABLE IF EXISTS " + Answers_Database.DATABASE_TABLE);
        onCreate(db);
    }
     public void createDataBase() throws IOException{

            boolean dbExist = checkDataBase();
        System.out.println("Create database");
            if(dbExist){

                System.out.println("database exists");

                //do nothing - database already exist.
            }else{

                System.out.println("database not exists");

                //By calling this method and empty database will be created into the default system path
                      //of your application so we are gonna be able to overwrite that database with our database.
                this.getReadableDatabase();

                try {

                    copyDataBase();

                } catch (IOException e) {

                    throw new Error("Error copying database");

                }
            }

           }
           @Override
        public synchronized void close() {

                if(myDataBase != null)
                    myDataBase.close();

                super.close();

        }
           private boolean checkDataBase(){

            SQLiteDatabase checkDB = null;

            try{
                String myPath = DB_PATH + DB_NAME;
                checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);

            }catch(SQLiteException e){

                //database does't exist yet.

            }

            if(checkDB != null){

                checkDB.close();

            }

            return checkDB != null ? true : false;
           }

           /**
            * Copies your database from your local assets-folder to the just created empty database in the
            * system folder, from where it can be accessed and handled.
            * This is done by transfering bytestream.
            * */
           private void copyDataBase() throws IOException{

               System.out.println("Copy STARTSSS");
            //Open your local db as the input stream
            InputStream myInput = mycontext.getAssets().open(DB_NAME);

            // Path to the just created empty db
            String outFileName = DB_PATH + DB_NAME;

            //Open the empty db as the output stream
            OutputStream myOutput = new FileOutputStream(outFileName);

            //transfer bytes from the inputfile to the outputfile
            byte[] buffer = new byte[1024];
            int length;

            while ((length = myInput.read(buffer))>0){
                myOutput.write(buffer, 0, length);
            }

            //Close the streams
            myOutput.flush();
            myOutput.close();

            myInput.close();

            System.out.println("CopYY DONE");
           }
           public void openDataBase() throws SQLException{

            //Open the database
               System.out.println("OPEN DATABASE");
               String myPath = DB_PATH + DB_NAME;
            myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);

           }



}

Please Help
Thanks

  • 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-06T23:44:27+00:00Added an answer on June 6, 2026 at 11:44 pm

    Remove the comment from second line of ON CREATE function in databasehelper class, update database version to 1333 and run.

    the on-create function is supposed to be invoked if every time even if the database is created for the first time or many times !

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

Sidebar

Related Questions

This is more like a question of principle. I made a table with 100%
Hi I made this site a while ago in my table days but have
I have a table in HTML. I have made this table as editable by
I have made the following code to retrive data from SQLite database. public Cursor
I've made a program that comunicates with a SQLite DB. Now, I'm trying to
My iphone app uses a SQLite database to store data. I have a table
I'm using eric4 (qtdesigner, pyqt, python, etc) with sqlite and I keep getting error
I made SQLite database table that stores records, is it possible to change some
The application I made currently use XML files to store data and now want
I'm trying to output a list from an SQLite database and am getting this

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.