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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:35:10+00:00 2026-05-31T18:35:10+00:00

I have a db that is created like this… public class DataBaseManager extends SQLiteOpenHelper{

  • 0

I have a db that is created like this…

public class DataBaseManager extends SQLiteOpenHelper{

    Context mContext;
    private static final String TAG = "DataBaseManager";
    private static final int dbVersion = 1;// ++ for DB  changes

    static final String dbName ="LCInstore";
    //Table Names
    static final String allIcons = "Icons";
    static final String allScreens = "Screens";
    static final String isLookUp = "LookUp";

    //Column Names - LookUp
    static final String colIconID = "IconID";
    static final String colScreenID = "ScreenID";
    static final String colRank = "Rank"; // order

    //Column Names shared by tables: Screens and Icons
    static final String colID = "ID";
    static final String colType = "Type";
    static final String colName = "Name";

    //Column Names - Icons
    static final String colImage = "Image";
    static final String colLabel = "Label";
    static final String colIntent = "Intent";
    static final String colIParams = "Params";


    public DataBaseManager(Context context) {
        super(context, dbName, null, dbVersion); 
        mContext = context;
        Log.v(TAG, "Initaited");

        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        Log.v(TAG, "on create called");

        // Create Icon Table if does not exist
         db.execSQL("CREATE TABLE "+ allIcons +"" +
                "("+colID + " INTEGER PRIMARY KEY AUTOINCREMENT, "+
                    colName + " TEXT," +
                    colImage + " BLOB," +
                    colLabel + " TEXT," +
                    colIntent + " TEXT," +
                    colType + " TEXT)");

        // Create Screens Table if does not exist
         db.execSQL("CREATE TABLE IF NOT EXISTS " + allScreens +"" +
                 "("+colID + " INTEGER PRIMARY KEY AUTOINCREMENT, "+
                    colName + " TEXT," +
                    colType + " TEXT)");

        //Create LookUp Table if does not exist
         db.execSQL("CREATE TABLE IF NOT EXISTS " + isLookUp +"" +
                 "("+colIconID + " INTEGER, "+
                    colScreenID + " INTEGER," +
                    colRank + " INTEGER)");

         InsertInitData(db);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub
        Log.v(TAG, "on upgrade called");
        //db.execSQL("DROP TABLE IF EXISTS "+allIcons);




    }


    private void InsertInitData(SQLiteDatabase db) {
        //screens
        ContentValues cv2=new ContentValues();
            cv2.put(colName, "DR_Home");
            cv2.put(colType, "dr_home");
            db.insert(allScreens, colID, cv2);
            cv2.put(colName, "DR_Sub");
            cv2.put(colType, "dr_sub");
            db.insert(allScreens, colID, cv2);

            //all Icons
        ContentValues cv=new ContentValues();

           cv.put(colName, "Icon1");
           cv.put(colImage, getBlobFromRes(R.drawable.dr_tablet_icon));
           cv.put(colLabel, "MY ICON 1");
           cv.put(colIntent, "someIntent");
           cv.put(colType, "generic");
           db.insert(allIcons, colID, cv);

           cv.put(colName, "Icon2");
           cv.put(colImage, getBlobFromRes(R.drawable.dr_tablet_icon));
           cv.put(colLabel, "MY ICON 2");
           cv.put(colIntent, "someIntent");
           cv.put(colType, "generic");
           db.insert(allIcons, colID, cv);

           cv.put(colName, "Icon3");
           cv.put(colImage, getBlobFromRes(R.drawable.dr_tablet_icon));
           cv.put(colLabel, "MY ICON 3");
           cv.put(colIntent, "someIntent");
           cv.put(colType, "generic");
           db.insert(allIcons, colID, cv);

           cv.put(colName, "Icon4");
           cv.put(colImage, getBlobFromRes(R.drawable.dr_tablet_icon));
           cv.put(colLabel, "MY ICON 4");
           cv.put(colIntent, "someIntent");
           cv.put(colType, "generic");
           db.insert(allIcons, colID, cv);

           cv.put(colName, "Icon5");
           cv.put(colImage, getBlobFromRes(R.drawable.dr_tablet_icon));
           cv.put(colLabel, "MY ICON 5");
           cv.put(colIntent, "someIntent");
           cv.put(colType, "generic");
           db.insert(allIcons, colID, cv);

           cv.put(colName, "Icon6");
           cv.put(colImage, getBlobFromRes(R.drawable.dr_tablet_icon));
           cv.put(colLabel, "MY ICON 6");
           cv.put(colIntent, "someIntent");
           cv.put(colType, "generic");
           db.insert(allIcons, colID, cv);

           cv.put(colName, "Icon7");
           cv.put(colImage, getBlobFromRes(R.drawable.dr_tablet_icon));
           cv.put(colLabel, "MY ICON 7");
           cv.put(colIntent, "someIntent");
           cv.put(colType, "generic");
           db.insert(allIcons, colID, cv);



        // icon screen lookups
        ContentValues cv3=new ContentValues();
            cv3.put(colIconID, 1);
            cv3.put(colScreenID, 2);
            cv3.put(colRank, 1);
            db.insert(isLookUp, colID, cv3);

            cv3.put(colIconID, 2);
            cv3.put(colScreenID, 2);
            cv3.put(colRank, 2);
            db.insert(isLookUp, colID, cv3);

            cv3.put(colIconID, 3);
            cv3.put(colScreenID, 2);
            cv3.put(colRank, 3);
            db.insert(isLookUp, colID, cv3);

            cv3.put(colIconID, 4);
            cv3.put(colScreenID, 2);
            cv3.put(colRank, 4);
            db.insert(isLookUp, colID, cv3);

            cv3.put(colIconID, 5);
            cv3.put(colScreenID, 2);
            cv3.put(colRank, 5);
            db.insert(isLookUp, colID, cv3);

            cv3.put(colIconID, 6);
            cv3.put(colScreenID, 2);
            cv3.put(colRank, 6);
            db.insert(isLookUp, colID, cv3);

            cv3.put(colIconID, 7);
            cv3.put(colScreenID, 2);
            cv3.put(colRank, 7);
            db.insert(isLookUp, colID, cv3);

    }

you’ll notice that one table, ‘allScreens’ or “Screens” has one row that in the Name column i am putting “DR_Home”

i do a query later to find out the value of the ID column of that row using this method and passing DR_Home to it:

public int getScreenID(String name){
        SQLiteDatabase db=this.getReadableDatabase();
        int sID;
        String selectQuery = "SELECT "+colID+ " FROM " + allScreens + " WHERE " + colName + "=" +name;
        Cursor c = db.rawQuery(selectQuery, null);
        sID = c.getInt(0);
        c.close();
        return sID;
    }

should return the value of the ID column but i am getting an error:

03-22 06:34:35.830: E/AndroidRuntime(29864): Caused by: android.database.sqlite.SQLiteException: no such column: DR_Home: , while compiling: select * from Screens WHERE Name=DR_Home

No such Column? im not asking for a column called DR_Home i am asking for the value of the ID column in the row where the Name column = DR_home.. at least thats what i thought.. i have messed up the syntax somewhere.. please help

  • 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-31T18:35:11+00:00Added an answer on May 31, 2026 at 6:35 pm

    Your query is wrong, as WHERE column = string will not work.

    String selectQuery = "SELECT "+colID+ " FROM " + allScreens + " WHERE " + colName + "=?";
    Cursor c = db.rawQuery(selectQuery, new String[] {name});
    

    Use ? which will be replaced by the second rawQuery() parameter. Strongly recommended.

    Not recommended: WHERE column = "string"

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

Sidebar

Related Questions

I have a control that is created like so: public partial class MYControl :
I have created a type like this: TypeBuilder tb = moduleBuilder.DefineType(myname, TypeAttributes.Class | TypeAttributes.Public,
I have a couple classes that look like this public class ParentClass { public
I have an application that creates a new app domain like this: private static
I have a table that's created like this: CREATE TABLE bin_test (id INTEGER PRIMARY
I have an NSBitmapImageRep that is created like this: NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc]
I have created a custom tag that looks like this: def textField = {
I have a database table that has 4 fields. It is created like this:
I have a strongly typed viewpage that I created that looks like this: <%@
I have an array that gets created from JSON. The array looks like 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.