Hi i'm new to android development.So i have comeup with a simple dictionary application.It should connects with sqlite database and show the meaning of an english word, when button clicks.The user enter the relevant word into a Edittext field and click the translate button.Then it should show the meaning on the same Edittext field.But in my code there is some problem.I can't find it.Other thing is my sqlite database size is 1.2 MB.Is it large for the android?It is in my assets folder.This is my code.Please help me to solve this.thanks...
package first.cdef.proj;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.database.sqlite.SQLiteDatabase;
import android.database.Cursor;
public class Translator_page extends Activity {
// Constants
public static final String DATABASE_NAME = "Word_reduced.sqlite";
public static final String TABLE_NAME = "WORD";
//public static final String COLUMN_ID = "ID";
public static final String COLUMN_ENGLISH = "ENGLISH";
public static final String COLUMN_MEANS = "MEANS";
private SQLiteDatabase newwordDB;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
Button nnext = (Button) findViewById(R.id.button3);
final EditText mEdit = (EditText)findViewById(R.id.editText1);
nnext.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String name = mEdit.getText().toString();
// Retrieve the new list of scores
Cursor c = newwordDB.query(TABLE_NAME, new String[] {
COLUMN_MEANS}, "COLUMN_ENGLISH like " +"%"+name+"%",
null, null, null, null,
null);
StringBuilder builder = new StringBuilder();
builder.append("Meaning");
c.moveToFirst();
if (c != null) {
// Loop through all Results
do {
builder.append("\n");
builder.append(c.getString(0));
}while(c.moveToNext());
}
//builder.append("</table></html>");
//mEdit.loadData(builder.toString(), "text/html", "UTF-8");
mEdit.append(builder.toString());
// Close the cursor
c.close();
}
});
}
@Override
protected void onResume() {
super.onResume();
newwordDB = openOrCreateDatabase(DATABASE_NAME,
SQLiteDatabase.CREATE_IF_NECESSARY
| SQLiteDatabase.OPEN_READWRITE, null);
newwordDB.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " ("
+ COLUMN_ENGLISH
+ " TEXT, " + COLUMN_MEANS + " TEXT)");
}
@Override
protected void onPause() {
super.onPause();
if (newwordDB.isOpen()) {
newwordDB.close();
}
}
}