I must create an application in android having a database.For the reason that database I've got a predefined listing of items.

Now,the truth is that my ap needs to offer towards the user the posibility introducing for the reason that list another items which aren't within the list.

As a result, I have produced an autocomplete text view by which I introduce something new and that i go ahead and take text fro autocomplete and I must write it within the database

Now,my issue is that after I display the items that I have introduced within the database,the toast text which i use to show things i have within the database it shows me nothing alongside "product......".

Now,that might be because after i try to obtain the text in the autocomplete I recieve nothing in exchange?

This is the way I just read from autocomplete:

mItem = (AutoCompleteTextView) findViewById(R.id.todo_edit_item);

String nou=mItem.getText().toString();

After which I compare nou(that is things i authored within the autocomplete) using what I've predefnied within the list,so if it's something new(that was not within the list already) the I add it within the database:

for(int i = 0; i < l; i++)

    {


       if (nou!=fruits[i])
                t=true;
        else t=false;

     }
    if (t==true)
    {
        db.insertTitle(nou);
        fruits=db.getAllfromDB("Fruits","fruit");
        l=l+1;
    }

Anybody any ideas of the items I am doing wrong in here cause I can not determine.I'lll be around for more particulars.Thank u ahead of time:)

You compare strings using != rather than using !nou.equals(fruits[i]). you also rival all elements in array every time, because you so t is definitely the need for the comparison towards the last aspect in the array whether a match was discovered or otherwise.

It ought to be written like this:

t = true;
for(int i = 0; i < l; i++)
{
   if (nou.equals(fruits[i]))
   {
            t=false;
            break;
   }
}
if (t==true)
{
    db.insertTitle(nou);
    fruits=db.getAllfromDB("Fruits","fruit");
    l=l+1;
}