@@ -0,0 +1,2518 @@
+package us.bmaupin.flashcards.arabic;%0A%0Aimport android.content.Context;%0Aimport android.database.Cursor;%0Aimport android.database.sqlite.SQLiteDatabase;%0Aimport android.database.sqlite.SQLiteOpenHelper;%0Aimport android.provider.BaseColumns;%0Aimport android.util.Log;%0A%0Apublic class RankDatabaseHelper extends SQLiteOpenHelper %7B%0A%09// tag for log messages%0A%09public static final String TAG = %22RankDatabaseHelper%22;%0A%0A    // The name of your database%0A    public static final String DATABASE_NAME = %22ranks.db%22;%0A    // The version of your database (increment this every time you change something)%0A    public static final int DATABASE_VERSION = 1;%0A    // The name of the table in your database%0A    public static final String DB_TABLE_NAME = %22ranks%22;%0A   %0A    // The name of each column in the database%0A    public static final String KEY_RANK = %22rank%22;%0A%0A    // SQL Statement to create a new database.%0A    public static final String DB_TABLE_CREATE =%0A        %22CREATE TABLE %22 + DB_TABLE_NAME + %22 (%22 +%0A        BaseColumns._ID + %22 INTEGER PRIMARY KEY AUTOINCREMENT, %22 +%0A        KEY_RANK + %22 INTEGER);%22;%0A   %0A    // The constructor method%0A    public RankDatabaseHelper(Context context) %7B%0A        super(context, DATABASE_NAME, null, DATABASE_VERSION);%0A    %7D%0A%0A    /* Called when the super class getWritableDatabase (or getReadableDatabase)%0A     * method determines that the database doesn't exist yet and needs to be created%0A     */%0A    @Override%0A    public void onCreate(SQLiteDatabase db) %7B%0A    %09Log.d(TAG, %22onCreate called%22);%0A        db.execSQL(DB_TABLE_CREATE);       %0A    %7D%0A%0A    /* Called when the super class getWritableDatabase (or getReadableDatabase)%0A     * method determines that the existing database isn't the same version as%0A     * the latest version%0A     */%0A    @Override%0A    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) %7B%0A        Log.w(TAG, %22Upgrading database from version %22 + oldVersion + %22 to %22%0A                + newVersion + %22, which will destroy all old data%22);%0A//        db.execSQL(%22DROP TABLE IF EXISTS %22 + DB_TABLE_NAME);%0A//        onCreate(db);%0A// TODO: upgrade the db properly%0A    %7D%0A    %0A    void initializeDb (SQLiteDatabase db, int totalRows) %7B%0A    %09String sql = %22SELECT COALESCE(MAX(_ID)+1, 0) FROM %22 + DB_TABLE_NAME;%0A    %09Cursor cursor = db.rawQuery(sql, null);%0A    %09cursor.moveToFirst();%0A    %09int existingRows = cursor.getInt(0);%0A    %09Log.d(TAG, %22initializeDb: existingRows=%22 + existingRows );%0A    %09cursor.close();%0A    %09%0A    %09// TODO: fill db with data up to number of total rows%0A    %7D%0A%7D%0A

add class for managing rank database