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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:10:09+00:00 2026-06-11T16:10:09+00:00

Still I’m pretty new on the Java and Android development. But in this part,

  • 0

Still I’m pretty new on the Java and Android development. But in this part, I could not find what is wrong. The LogCat return “no such table: translations”.

package se.maxallan.birdsound;

    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 SpeciesDbAdapter extends SQLiteOpenHelper{
    public static final String DB_SPECIE_ID = "_id";
    public static final String DB_SCF_NAME = "scf_name";

    public static final String DB_T_LANG = "lang";
    public static final String DB_T_TRANS = "translated";

    private static SpeciesDbAdapter mDbHelp;
    private static SQLiteDatabase mDb;

    private static final String DB_NAME = "database.db";
    private static final String DB_TBL_SPECIES = "species";
    private static final String DB_TBL_TRANSLATIONS = "translations";
    //private static final String DB_TBL_SOUNDS = "sounds";
    private static final int DB_VERSION = 1;

    private final Context mCtx;

    static String createSpecies = "CREATE TABLE if not exists "
    + DB_TBL_SPECIES 
    +" ("+DB_SPECIE_ID +" INTEGER PRIMARY KEY AUTOINCREMENT,"
    +DB_SCF_NAME+");"; 

    static String createTranslations = "CREATE TABLE if not exists "
    + DB_TBL_TRANSLATIONS
    +" (tid INTEGER PRIMARY KEY AUTOINCREMENT,"
    +DB_SPECIE_ID+","
    +DB_T_TRANS+","
    +DB_T_LANG+");"; //The error is here?

    public SpeciesDbAdapter(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
        this.mCtx = context;
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(createSpecies);
        db.execSQL(createTranslations);
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }

    //Open the database
    public SpeciesDbAdapter open() throws SQLException {
        mDbHelp = new SpeciesDbAdapter(mCtx);
        mDb = mDbHelp.getWritableDatabase();
        return this;
    }
    //Close the connection
    public void close() {
        if (mDbHelp != null) {
            mDbHelp.close();
        }
    }

    public void addSpecie(String scf, String translation, String lang){
        ContentValues specieValues = new ContentValues();
        ContentValues translationsValues = new ContentValues();
        specieValues.put(DB_SCF_NAME, scf);
        int LastInsertedId = (int) mDb.insert(DB_TBL_SPECIES, null, specieValues);
        translationsValues.put(DB_T_LANG, lang);
        translationsValues.put(DB_T_TRANS, translation);
        translationsValues.put(DB_SPECIE_ID, LastInsertedId);
        mDb.insert(DB_TBL_TRANSLATIONS, null, translationsValues);
    }

    public Cursor fetchAllSpecies() {
        Cursor mCursor = mDb.rawQuery("select * from "+ DB_TBL_SPECIES +" s inner join "+ DB_TBL_TRANSLATIONS +" t on s._id=t._id", null);
        Log.d("Database", "Result cursor size " + mCursor.getCount() );
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        return mCursor;
    }
    public void insertSomeSpecies() {
        addSpecie("Cygnus olor", "Knölsvan", "sv");
        addSpecie("Cygnus cygnus", "Sångsvan", "sv");
    }

    }

I think that the error is were I create the table translations – or try to create…

  • 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-11T16:10:10+00:00Added an answer on June 11, 2026 at 4:10 pm

    I’m guessing that you ran your app at least one with only one table:

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

    And then you added:

        db.execSQL(createTranslations);
    

    The OpenHelper will not check for any changes here automatically. You have to force the database to be recreated. I think the easiest way to do this is by increasing your DB_VERSION.

    private static final int DB_VERSION = 2;
    

    This will run onUpgrade() which should drop the existing schema and creates your new one.

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + DB_TBL_SPECIES);
        db.execSQL("DROP TABLE IF EXISTS " + DB_TBL_TRANSLATIONS);
        onCreate(db);
    }
    

    The next time you change your schema simply change one number (DB_VERSION = 3) and your new tables will be built.

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

Sidebar

Related Questions

still pretty new to android I have to clone an iphone application. Im having
Still new to .NET, but this looks OK to me. I can't figure out
Still pretty green on clojure, java, layouts etc. On a miglayout I have this
Still new to ASP MVC development. Suppose I have a MusicController that has 2
Still fairly new to android, wondered if anyone can help... I have an App
Still working on this part of my script to parse my JSON jsonArray =
Still working my way around this, but is there any function/command I can use
still fairly new to matlab, picked up this data analysis code from someone and
still fairly new to ruby, and wrote this very simple recursive function. def test(input)
Still relatively new to Java and I'm wondering which is the better way to

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.