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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:56:21+00:00 2026-05-15T19:56:21+00:00

So basically my app starts out with a TabView, then through the options menu

  • 0

So basically my app starts out with a TabView, then through the options menu the user selects to add a game to the database. This opens the InputGame class, which accepts a few values, and then it should put them into a database when the user clicks “Submit”. It will also go back to the original home view. The app goes back the the home tabs view just fine, bu nothing ever gets added to the database. Am I doing something wrong?

InputGame:

public class InputGame extends Activity {

    private EditText gameTitle;
    private Spinner consoleSelect;
    private Spinner genreSelect;
    private Spinner ratingSelect;
    private Spinner styleSelect;
    private EditText gamePub;
    private EditText gameDev;
    private EditText gameRegion;
    private EditText gamePrice;
    private EditText gameRelease; 

    private DatabaseHelper db = null;
    private Cursor constantsCursor=null;
    private Button addGame;



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.inputgame);

        db = new DatabaseHelper(this);
        constantsCursor = db.getReadableDatabase().rawQuery(
                "SELECT _ID, title, console " + "FROM constants ORDER BY title",
                null);


        /*Hide the scroll bar*/
        ScrollView sView = (ScrollView)findViewById(R.id.ScrollInput);
        sView.setVerticalScrollBarEnabled(false);
        sView.setHorizontalScrollBarEnabled(false);

        /* Accepts game title */
        gameTitle = (EditText) findViewById(R.id.gametitle);        

        /* Console select*/ 
        consoleSelect = (Spinner) findViewById(R.id.console_select);
        ArrayAdapter<CharSequence> consoleAdapter = ArrayAdapter.createFromResource(
                this, R.array.consoles_array, android.R.layout.simple_spinner_item);
        consoleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        consoleSelect.setAdapter(consoleAdapter);


        /* Genre select*/   
        genreSelect = (Spinner) findViewById(R.id.genre_select);
        ArrayAdapter<CharSequence> genreAdapter = ArrayAdapter.createFromResource(
                this, R.array.genres_array, android.R.layout.simple_spinner_item);
        genreAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        genreSelect.setAdapter(genreAdapter);

        /* Style  select*/  
        styleSelect = (Spinner) findViewById(R.id.style_select);
        ArrayAdapter<CharSequence> styleAdapter = ArrayAdapter.createFromResource(
                this, R.array.style_array, android.R.layout.simple_spinner_item);
        styleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        styleSelect.setAdapter(styleAdapter);

        /* Rating select*/  
        ratingSelect = (Spinner) findViewById(R.id.rating_select);
        ArrayAdapter<CharSequence> ratingAdapter = ArrayAdapter.createFromResource(
                this, R.array.ratings_array, android.R.layout.simple_spinner_item);
        ratingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        ratingSelect.setAdapter(ratingAdapter);

        /* Accepts game publisher */
        gamePub = (EditText) findViewById(R.id.gamepublisher);

        /* Accepts game developer */
        gameDev = (EditText) findViewById(R.id.gamedev);




        /* Release date selector */
        gameRelease = (EditText) findViewById(R.id.gamerelease);

        /* Add the game button */
        this.addGame = (Button)this.findViewById(R.id.addgame);
        this.addGame.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                processAdd();
            }


        });


    }
    private void processAdd(){
        ContentValues values=new ContentValues(8);

        values.put("title", getGameTitle());
        values.put("console", getGameConsole());
        values.put("genre", getGameGenre());
        values.put("style", getGameStyle());
        values.put("rating", getGameRating());
        values.put("publisher", getGamePublisher());
        values.put("developer", getGameDeveloper());
        values.put("release", getGameRelease());

        db.getWritableDatabase().insert("constants", "title", values);
        constantsCursor.requery();
        Intent launchgamesActivity = new Intent(this, GCM.class);
        startActivity(launchgamesActivity);
    }
    public String getGameTitle(){
        return(gameTitle.getText().toString());
    }
    public String getGameConsole(){
        return (consoleSelect.getContext().toString());
    }
    public String getGameGenre(){
        return(genreSelect.getContext().toString());
    }
    public String getGameStyle(){
        return(styleSelect.getContext().toString());
    }
    public String getGameRating(){
        return(ratingSelect.getContext().toString());
    }
    public String getGamePublisher(){
        return(gamePub.getText().toString());
    }
    public String getGameDeveloper(){
        return(gameDev.getText().toString());
    }
    public String getGameRelease(){
        return(gameRelease.getText().toString());
    }}

and here is my database helper. The records I have pre-programmed in show up just fine:

public class DatabaseHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "gameDb";
    public static final String TITLE="title";
    public static final String CONSOLE="console";
    public static final String GENRE="genre";
    public static final String RATING="rating";
    public static final String PUBLISHER="publisher";
    public static final String DEVELOPER="developer";
//  public STATIC FINAL STRING REGION="REGION";
    public static final String PRICE="price";
    public static final String RELEASE="release";
    public static final String COMPLETION="completion";
    public static final String DESCRIPION="description";
    public static final String IMAGE="image";

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db
                .execSQL("CREATE TABLE constants (_id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, console TEXT, genre TEXT, " +
                "rating TEXT, publisher TEXT, developer TEXT, region TEXT, price REAL, release BLOB, completion BLOB, description BLOB, image BLOB);");

        ContentValues cv = new ContentValues();

        cv.put(TITLE, "Super Mario Galaxy");
        cv.put(CONSOLE, "Wii");
        db.insert("constants", TITLE, cv);

        cv.put(TITLE, "Transformers: War for Cybertron");
        cv.put(CONSOLE, "Xbox 360");
        db.insert("constants", TITLE, cv);

        cv.put(TITLE, "Final Fantasy XIII");
        cv.put(CONSOLE, "Playstation 3");
        db.insert("constants", TITLE, cv);

        cv.put(TITLE, "Final Fantasy VII");
        cv.put(CONSOLE, "Playstation");
        db.insert("constants", TITLE, cv);

        cv.put(TITLE, "New Super Mario Bros");
        cv.put(CONSOLE, "Nintendo DS");
        db.insert("constants", TITLE, cv);


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        android.util.Log.w("Constants",
                "Upgrading database, which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS constants");
        onCreate(db);
    }
}

EDIT: When submitting from InputGames, should I be closing that activity all together? I think the way I have it set now just goes back to the other activity, but nothing really gets done. Or is that not it at all?

EDIT #2 Well I got it to add. For some reason I have to use .execSQL. Thats fine I guess, but bow when I try to add from a spinner item in InputGames, I get this populating the respective element:

com.jvavrik.gcm.InputGame@43bb0510

were the number after the “@” is always different. Any ideas for this?

  • 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-15T19:56:22+00:00Added an answer on May 15, 2026 at 7:56 pm

    What if you change this:

    db.getWritableDatabase().insert("constants", "title", values);
    

    to this:

    db.getWritableDatabase().insert("constants", null, values);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically the app writes the contents of a Collection to XML. I'm using XMLStreamWriter
Basically what I want to do it this: a pdb file contains a location
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
I'm getting Flex error #2007, right when the app starts up. TypeError: Error #2007:
Basically I have some code to check a specific directory to see if an
Basically I'm going to go a bit broad here and ask a few questions
Basically, I would like a brief explanation of how I can access a SQL
Basically I am trying to restart a service from a php web page. Here
Basically, I'm trying to tap into the Soap pipeline in .NET 2.0 - I
Basically I’ve heard that certain conditions will cause .NET to blow past the finally

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.