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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:48:14+00:00 2026-05-31T21:48:14+00:00

I am trying to figure out what order I need to do everything to

  • 0

I am trying to figure out what order I need to do everything to have my program flow well and not crash. I want the player of my game to have a team of three people each as their own class with stats such as attack, health, etc.

  1. When the game is first installed and run, I want to have a sqlite db made and filled with the 3 starter characters.
  2. When they start it any other time, I want to have the three stored characters in the DB to be assigned to 3 local character objects.

I have a SQLite Adapter class handling the Db but I’m not sure how to order everything so that I check first to see if there is a Db in the programs Db path and open it if there is. Otherwise just create a new one and populate it with the initial characters.

I currently have:

DbAdapter = new PlayerDbAdapter(this);
    DbAdapter.open();
    DbAdapter.setInitialPlayers();    // inserts my initial player object info into the Db

which calls

public PlayerDbAdapter open() throws SQLException {
        dbHelper = new SummonSQLiteHelper(context);
        String s = DbPath + DB_NAME;
        database = SQLiteDatabase.openOrCreateDatabase(s, null);
        return this;
}

And now I’m a little lost as to what I need to make sure that I don’t overwrite any saved info in the Db with the initial values everytime I start the program. Any suggestions?

  • 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-31T21:48:15+00:00Added an answer on May 31, 2026 at 9:48 pm

    Try like this

    public PlayerDbAdapter open() throws SQLException {
        dbHelper = new SummonSQLiteHelper(context);
        String s = DbPath + DB_NAME;
        bool b=checkDataBase(s);
       if(b==false)
        {
            database = SQLiteDatabase.openOrCreateDatabase(s, null);
            setInitialPlayers(); <---- set initial values here
         }
      else
      {
        database = SQLiteDatabase.openOrCreateDatabase(s, null);
    
      }
      return this;
       }
        private boolean checkDataBase(String str) {
        SQLiteDatabase checkDB = null;
    try {
        checkDB = SQLiteDatabase.openDatabase(str, null,
                SQLiteDatabase.OPEN_READONLY);
        checkDB.close();
    } catch (SQLiteException e) {
        // database doesn't exist yet.
    }
    return checkDB != null ? true : false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to figure out why this is happening - I have an input text
Trying to figure out how to type (via events not set the value) on
I'm trying to figure out what rate of return I would need on an
I have been trying to figure out the best practices to write test-friendly code,
Im trying to figure out if this is possible. I want to sort by
I have been trying to figure out how to use JAX-RS for quite some
My head is spinning trying to figure out the SQL query I need to
I need some help. I am trying to figure out how to schedule jobs
I have been trying to figure out this query for a few hours now
I'm trying to figure out how to order items with matching tags by the

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.