i already saw that thread but i still can't understand some of the
codes... i don't know how to incorporate my database in that code...
how can i import my db...


public ContactListAdapter(Context context, Cursor c) {
                    super(context, c);
                    Log.d("exp", "******************* A VER EHJEE
*****************");
                    mDb = new Database
(context);
<------- (is this where i will put my DB?)
                    mDb.open();
                    Log.d("exp", "******************* A VER PUES 100
*****************");
                }

 private static final String[] PEOPLE_PROJECTION = new String[]
<----- (is this where autocomplete extracts its data?)
{
                Database.KEY_REASON,
                Database.KEY_VALUE,
                Database.KEY_TAX
        };

sorry guyz... im kinda new on this whole thing....
tnx for any of your help...



On Mar 5, 6:42 pm, roland <[email protected]> wrote:
> Check this 
> out,http://groups.google.com/group/android-developers/browse_thread/threa...
>
> On 4 mar, 07:22, aljo <[email protected]> wrote:
>
>
>
> > i'm kinda new to this android application and still a newbei to
> > programming so hope someone could help me....
>
> > i've created an SQLitedatabaseprogram.. but i don't know how to use
> > theautocompletefunction to access mydatabase... here's my code:
>
> > ---------------------------------------------------------------------------­-----------------------------------------------------------
>
> > packagedatabase.dev5;
>
> > import java.util.ArrayList;
>
> > import android.app.ListActivity;
> > import android.database.Cursor;
> > import android.database.sqlite.SQLiteDatabase;
> > import android.os.Bundle;
> > import android.widget.ArrayAdapter;
> > import android.widget.EditText;
>
> > public classDatabaseextends ListActivity {
>
> >         private final String MY_DATABASE_NAME = "myCoolDB_2";
> >         private final String MY_DATABASE_TABLE = "Users";
>
> >         /** Called when the activity is first created. */
> >         @Override
> >         public void onCreate(Bundle icicle) {
> >                 super.onCreate(icicle);
>
> >                 EditText et = new EditText(this);
> >                 et.setSelection(et.getText().length());
> >                 /* Will hold the 'Output' we want to display at the end. */
> >                 ArrayList<String> results = new ArrayList<String>();
>
> >                 SQLiteDatabase myDB = null;
> >                 try {
>
> >                         //Create theDatabase(no Errors if it already exists)
> >                         this.openOrCreateDatabase(MY_DATABASE_NAME, 
> > MODE_PRIVATE, null);
> >                         // Open the DB and remember it
> >                         myDB = this.openOrCreateDatabase(MY_DATABASE_NAME, 
> > MODE_PRIVATE,
> > null);
>
> >                         //this.deleteDatabase(MY_DATABASE_NAME);
>
> >                         // Create a Table in theDatabase.
> >                         myDB.execSQL("CREATE TABLE IF NOT EXISTS "
> >                                                         + MY_DATABASE_TABLE
> >                                                         + " (English 
> > VARCHAR, Japanese VARCHAR,"
> >                                                         + " MASU_Form 
> > VARCHAR, Definition VARCHAR);");
>
> >                         //myDB.delete(MY_DATABASE_TABLE, null, null);
>
> >                         // Add two DataSets to the Table.
> >                         /*myDB.execSQL("INSERT INTO "
> >                                                         + MY_DATABASE_TABLE
> >                                                         + " (English, 
> > Japanese, MASU_Form, Definition)"
> >                                                         + " VALUES ('yes', 
> > 'hai', 'NA', 'noun');");
> >                         myDB.execSQL("INSERT INTO "
> >                                                         + MY_DATABASE_TABLE
> >                                                         + " (English, 
> > Japanese, MASU_Form, Definition)"
> >                                                         + " VALUES ('yes', 
> > 'ee', 'NA', 'noun');");
> >                         myDB.execSQL("INSERT INTO "
> >                                                         + MY_DATABASE_TABLE
> >                                                         + " (English, 
> > Japanese, MASU_Form, Definition)"
> >                                                         + " VALUES ('call', 
> > 'kakeru', 'kakemasu', 'verb: to call');");
> >                         myDB.execSQL("INSERT INTO "
> >                                                         + MY_DATABASE_TABLE
> >                                                         + " (English, 
> > Japanese, MASU_Form, Definition)"
> >                                                         + " VALUES ('call', 
> > 'kakeru', 'kakemasu', 'verb: to wear');");
> >                         myDB.execSQL("INSERT INTO "
> >                                                         + MY_DATABASE_TABLE
> >                                                         + " (English, 
> > Japanese, MASU_Form, Definition)"
> >                                                         + " VALUES ('call', 
> > 'kakeru', 'kakemasu', 'verb: to
> > hang');");*/
>
> >                         //myDB.delete(MY_DATABASE_TABLE, "LastName" + "=" + 
> > "'Ponce'",
> > null);
> >                         //myDB.delete(MY_DATABASE_TABLE, null, null);
>
> >                         //Query for some results with Selection and 
> > Projection.
> >                         /*Cursor c = myDB.query(MY_DATABASE_TABLE,
> >                                         new String[] {"FirstName, Age "}, 
> > null,
> >                                         null, null, null, null, "7");  */
>
> >                         Cursor c = myDB.query(MY_DATABASE_TABLE,
> >                                         new String[] {"English, Japanese , 
> > MASU_Form, Definition"},
> >                                         "Japanese" + "=" + "'kakeru'", 
> > null, null, null, null, "7");
>
> >                         // Get the indices of the Columns we will need
> >                         int EnglishColumn = c.getColumnIndex("English");
> >                         int JapaneseColumn = c.getColumnIndex("Japanese");
> >                         int MASU_FormColumn = c.getColumnIndex("MASU_Form");
> >                         int DefinitionColumn = 
> > c.getColumnIndex("Definition");
>
> >                         // Check if our result was valid.
> >                         if (c != null) {
> >                                 //Check if at least one Result was returned.
> >                                 if (c.moveToFirst()) {
> >                                         int i = 0;
> >                                         // Loop through all Results
> >                                         do {
> >                                                 i++;
> >                                                 //Retrieve the values of 
> > the Entry
> >                                                  // the Cursor is pointing 
> > to.
> >                                                 String english = 
> > c.getString(EnglishColumn);
> >                                                 String japanese = 
> > c.getString(JapaneseColumn);
> >                                                 String masu_form = 
> > c.getString(MASU_FormColumn);
> >                                                 String definition = 
> > c.getString(DefinitionColumn);
>
> >                                                 //Add current Entry to 
> > results.
> >                                                 results.add("(" + i + ") " 
> > + english + ", " + japanese + ", " +
> > masu_form + ", " + definition);
>
> >                                         } while (c.moveToNext());
> >                                 }
> >                         }
>
> >                 //} catch (FileNotFoundException e) {
> >                 } finally {
> >                         if (myDB != null)
> >                                 myDB.close();
> >                 }
>
> >                 this.setListAdapter(new ArrayAdapter<String>(this,
> >                                 android.R.layout.simple_list_item_1, 
> > results));
> >         }
>
> > }
>
> > ---------------------------------------------------------------------------­-------------------------------------------------------------
>
> > would appreciate any help... thanks...- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to