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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:57:39+00:00 2026-05-24T21:57:39+00:00

I need to recognize first launch of my application or activity. At this time

  • 0

I need to recognize first launch of my application or activity.

At this time I need to get some information from server create local database and save info to it. What is the best way to do this?

  1. Create any preferences for example FirstLaunch and set true \ false to it.
  2. Check whether my database exists or not.
  3. Something else?

PS. All server calls must be into one transaction. Ormlite supports transactions?
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-05-24T21:57:40+00:00Added an answer on May 24, 2026 at 9:57 pm

    For the “create database at first run”-purpose, you should use an SQLiteOpenHelper, which offers you the onCreate()-method that is called when:

    […] the database is created for the first time.

    The Database-file itself will be created for you (you don’t have to do this manually). In this method, you can then perform actions like populating your database with standard entry’s.


    If you want to populate the database with informations you get from your server, there might be a problem when there is no Internet-connection available.

    In this case, I would check if there is a connection available:

    • If there is, get your informations.
    • If not, show a Toast or some other notification to inform the user.

    To determine if your Database has be populated with the standard entry’s, you can use the database-version which is also provided by the SQLiteDatabase-class:

    • When you first create your Database-object, you call
      SQLiteOpenHelpers constructor and pass it 0 as the Database
      version.
    • If you successfully populated your database, you use
      setVersion()-method to alter it to 1.
    • Later in the onOpen()-method, which is called when the
      database is opened, you can check if the database was populated by
      using the getVersion()-method.

      • If it is populated, call the super-method to open it.
      • If not, try populating it.

    Further more, the getReadableDatabase() / getWritableDatabase()-methods should be called off the main-thread anyways because:

    Database upgrade may take a long time, you should not call this method
    from the application main thread, including from
    ContentProvider.onCreate().

    So getting the informations from the Internet can take place in the onCreate() and in the onOpen()-method (if it wasn’t successful at the first try). You can (for example) use a Service to do this.

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

Sidebar

Related Questions

I am building my first Silverlight 3 + RI Services application and need some
First off I'm horrible with regex, hoping I can get some help here cause
I need the program that can be recognize the largest value in text. First
What I'm trying is this: 1) Create a new manged object 2) Get it's
I am working on a on-screen keyboard for Android, and I need to recognize
I asked a similar question yesterday, but recognize that i need to rephase it
I'm curious, why does sed need 3 \ just to recognize one? I'd understand
need ask you about some help. I have web app running in Net 2.0.
Need some help about with Memcache. I have created a class and want to
I have a calculation application which I need to validate the fields to check

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.