Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,195,428 members, 7,958,281 topics. Date: Wednesday, 25 September 2024 at 11:50 AM

Android Dictionary Application With Search Suggest And Text To Speech Feature - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Android Dictionary Application With Search Suggest And Text To Speech Feature (3071 Views)

Simple Text-To-Speech Program using Vbscript. Do It Yourself. / Text-to-Speech For Nigerian Languages / Android Quiz Application With Json Parser, Php And Mysql Database (2) (3) (4)

(1) (Reply) (Go Down)

Android Dictionary Application With Search Suggest And Text To Speech Feature by nollyj2: 10:42am On Apr 12, 2015
In this android tutorial we are going to learn how to create an android dictionary application with Search Suggest and Text to Speech feature. The android application can be used in defining terms or words use in a particular field.

You can found an example of Biology Dictionary I built in one of my apps in the Google Play Store.

The app will consist of different words and their meaning. When a word is selected, it will display the definition or meaning of the word with an option to convert it to speech.

The app will also has a search functionality with integrated search suggestion. When a user type in two characters the search box will display all the words that contain the type in characters.

If you still don't understand what search suggest means you can read my post on Android ListView with EditText Search Filter

We will start by designing android SQLITE database that will house our data. There are different ways we can use to create our database. In this tutorial, I am going to use a SQLITE Manager to create and manager the database file.

The database will be create using SQLite Expert Professional Manager which is a paid software but there are many free to use SQLite Manager you can get online and use.

I will go ahead and create a database called dictionary. Now, we have to create a table inside our database called dictionary. The table will have three columns – id, word and meaning. The SQLite code for the table is shown below.

Create Table [dictionary] (
[_id] INTEGER PRIMARY KEY,
[word] TEXT,
[meaning] TEXT
);


Before we start, the first thing I will do is to list the environment and tools I used in this android tutorial but feel free to use whatever environment or tools you are familiar with.

Windows 7
Android Studio
Samsung Galaxy Fame Lite
Min SDK 14
Target SDK 19

To create a new android application project, following the steps as stipulated below.

Go to File menu
Click on New menu
Click on Android Application
Enter Project name: AndroidDictionaryApplication
Package: com.inducesmile.androiddictionaryapplication
Keep other default selections.
Continue to click on next button until Finish button is active, then click on Finish Button

Once you are done with creating your project, make sure you change the package name if you did not use the same package.

1 Like

Re: Android Dictionary Application With Search Suggest And Text To Speech Feature by ITbomb(m): 11:00am On Apr 12, 2015
Following

1 Like

Re: Android Dictionary Application With Search Suggest And Text To Speech Feature by nollyj2: 9:08am On Apr 13, 2015
SQLITE Database
We will start from the backend and build the application to finish. The first thing we will do is to create a folder called databases inside assets folder. Since we created our SQLite database file using SQLite database manager, we will drag and drop the file inside the databases folder and zip.

We are preparing our database file this way since we are going to use a third party library called android sqlite asset helper. This library will help us to create and manage your database file. You can read more about this library here.

The next to do is the import the library to our project. Since the library makes use of gradle, just open your build.gradle file and copy and paste the code below under the dependence section.

compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'

Now you can build your project and the library will be added automatically to your project. If you are using Eclipse for you android development, you can search on how to import library inside android project.

We will go ahead with the SQLite database code now that we have finished setting up our database library.

We will create three different files – DictionaryDatabase.java, DatabaseObject.java and DbBackend.java.

The DictionaryDatabase java class will inherit from SQLiteAssetHelper which is a class from our imported library. We will define our database name and version. The version number is use to control our application database update.

Whenever there is a change in the database file, the version number will be updated. The code sample is shown below. Copy and paste it to your project file.

import android.content.Context;
import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
public class DictionaryDatabase extends SQLiteAssetHelper {
private static final String DATABASE_NAMES = "quiz";
private static final int DATABASE_VERSION = 5;

public DictionaryDatabase(Context context) {
super(context, DATABASE_NAMES, null, DATABASE_VERSION);
// TODO Auto-generated constructor stub
}
}


We are going to establish a connection for our database and return the instance of our database in DatabaseObject.java file. An instance of the DictionaryDatabase is created and the getReadableDatabase of the class is used to get the connection object. The getter and close methods in the class is used to return and close the database connection. The code for this class is shown below.

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
public class DbObject {
private static DictionaryDatabase dbHelper;
private SQLiteDatabase db;
public DbObject(Context context) {
dbHelper = new DictionaryDatabase(context);
this.db = dbHelper.getReadableDatabase();
}
public SQLiteDatabase getDbConnection(){
return this.db;
}
public void closeDbConnection(){
if(this.db != null){
this.db.close();
}
}
}

(1) (Reply)

How To Learn Data Science As A Complete Beginner To PRO Status / Need Help With My Codes. / Gradle Problem In Android Studio

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 18
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.