Phone: +66-94-257-9379

Email:contact@appnomads.com

Beatrice Krell
2016-05-18 18:05:41
Android ADB Terminal, Android AVD Manager, SQLite Database, Android SQLiteOpenHelper, Fitness Manager
0 Comments
mobile-form-db-data

After the description of all the Layout issues, I had to struggle with while developing my first Android App Fitness Manager, this time I want to write about databases in Android Apps. The Layout of the Fitness Manager App had to be filled with data, statistics and life.

The integration of a SQLite database in Android Apps is very simple and easy. The developer just needs to implement a Java subclass that overwrites the functions onCreate and onUpgrade of the Android SQLiteOpenHelper API. In order to access the subclass an object of the subclass has to be instantiated.

java-class-extending-sqliteopenhelper

Finished :-)

No but almost. Now tables have to be created, deleted and filled with values. Many database operations can be handled in different ways with Android SQLiteOpenHelper.

1. Create a table by just executing a SQL command.

sql-command-create-table

2. Delete a table by just executing a SQL command.

sql-command-delete-table

3. Insert an entry into a table by just executing a SQL command.

sql-command-insert-table-entry

Insert an entry into a table by using Android SQLiteOpenHelper API. The function getWriteableDatabase has to be called in the beginning of the operation when putting entries into databases.

sqlliteopenhelper-insert-table-entry

4. Updating an entry of a table by using Android SQLiteOpenHelper API. The function getWriteableDatabase has to be called in the beginning of the operation when updating entries of databases.

sqlliteopenhelper-update-table-entry

5. Delete an entry from a table by just executing a SQL command.

sql-command-delete-table-entry

6. Selecting a single row entry from a table of the database by using Android SQLiteOpenHelper. The function getReadableDatabase has to be called in the beginning of the operation when selecting entries from databases.

sqlliteopenhelper-select-single-from-table

7. Selecting multiple row entries from a table of the database by using Android SQLiteOpenHelper. The function getReadableDatabase has to be called in the beginning of the operation when selecting entries from databases.

sqlliteopenhelper-select-multiple-from-table

These are the most convenient operations and functions for implementing a SQLite database for Android Apps.

In order to receive the data of the database in a virtual Android device of Android Studio, the Android AVD Manager can be used. The Android AVD Manager can be found within Tools – Android – AVD Manager or you just click the corresponding ImageButton in the Toolbar of Android Studio.

avd-manager-toolbar

Within the Android AVD Manager the developer has to switch to the File Explorer tab. After selecting the virtual device in Android AVD Manager, the database can be found in data/data/[package_name]/databases/.db. The database file can be pulled from virtual device by using the small ImageButton in the right top corner of the Android AVD Manager.

avd-manager-file-explorer

In order to receive the data of the database in a real device, the Android ADB Terminal has to be used. The data of a real device is not accessable with the AVD Manager of the Android Studio. The Android ADB Terminal can be found in the folder /Android/sdk/platforms-tools. Most often this directory is located in the user directory. A terminal must be opened at this directory and the PULL command is executed for ADB.

adb-terminal

The data of the database can be verified using the SQLiteManager of Firefox. This tool can be found within Firefox – Extras.

That's it. Sweet.

If you have any questions, any improvement suggestions for the implementation (I mentioned that this is my first Android App) or any improvement suggestions for my English, I really would appreciate if you can leave me a comment.

And I would even more appreciate if you like to check out the 'Fitness Manager' App in the Google Play Store or the 'Fitness Manager' App in the iTunes Store. See you.


Follow us on

Facebook
Twitter
Google Plus

Contact Details

Telephone: +66-94-257-9379
Mail: contact@appnomads.com
Website: www.appnomads.com

Hot and quiet place with WiFi

Woktom,
Koh Phangan,
Thailand