Hesham Saeed
Hesham Saeed

Reputation: 5378

Android SQLite database and SharedPreferences

I have an application with like 400 records in the database, I have splash screen in the beginning, I have AsyncTask inserting the data in the database and onPostExecute() I close the splash screen and the application goes. Ofcourse I want this to happen only one time so when the user open the app in another time he don't occur duplication of data. So I created boolean SharedPrefernces for first visit. Now the question is, suppose I updated the application in the market, the user will have to replace the application, does the sharedprefernces value get back to the default?

I know that I have to insert the data inside onCreate() of the database handler/helper but it takes time to insert 400 records with many fields, so I made the splash screen with background execution.

Please tell me if what i'm doing is OK or I need to change the structure and put the insertion inside onCreate().

Thank you.

Upvotes: 0

Views: 313

Answers (1)

cottonBallPaws
cottonBallPaws

Reputation: 21620

SharedPreferences and all of the app's data (such as sql databases) are maintained through app upgrades. The only time that data will be deleted or reset is if the user uninstalls the app.

Upvotes: 2

Related Questions