1

Am completely new to android development(from J2EE,Spring and Oracle background). Just trying to create a logo quiz app in android. Am planning my simple sqlite db structure to be,

  1. unique image name
  2. answer for the logo image(to check with user input)
  3. whether answered or not (just a flag)
  4. if answered, then points.

As soon as the user installs the app, the table has to be created with all the values. Now, my doubt would be, how to store this data? If i code this storing logic in an activity, then every time when the activity is started, would we be creating a new db and store it? where the coding logic for this initial storage would go?

Any help is much appreciated for this dummies question... Thanks in advance...

Yali
  • 44
  • 6

4 Answers4

0

you could use the HTML5 local storage to store the data.

RCW
  • 121
  • 2
  • 6
  • Yea.. thats another option... But as long as i googled, everyone suggested for db.... – Yali Nov 28 '12 at 03:07
0

try this code to check wether or not your database is exist

private boolean checkDataBase(){

        SQLiteDatabase checkDB = null;

        try {

            String myPath = DB_PATH + DB_NAME;
            checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);

        } catch (SQLiteException e) {
            // TODO: handle exception
        }

        if(checkDB != null){
            checkDB.close();
        }

        return checkDB != null;
    }

so if it return true you don't need to create a new database

or you also can learn from this link

danzer
  • 126
  • 2
  • 7
  • Thanks danzer.. Thats really an useful link.. guess i got the flow now.. thks again.. – Yali Nov 28 '12 at 03:15
0

use SharedPreferences to store application data.

for example of SharedPreferences you can find thousands of links , here are two

http://saigeethamn.blogspot.com/2009/10/shared-preferences-android-developer.html

and the api doc is here

http://developer.android.com/reference/android/content/SharedPreferences.html

But if you want to store large amount of data and then better use database (or file in some cases)

stinepike
  • 54,068
  • 14
  • 92
  • 112
  • Yea.. SharedPreferences are also an option.. But i thought sql would be a good place to start... thanks for the suggestion though.. – Yali Nov 28 '12 at 03:17
0

yes. It should be simple with sqlite. first of Its very Important to learn about sqlite from the official website from here

and after that refer the examples from here

Use of SQLite

Using SQLite on Android

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78