views:

93

answers:

1

Here is my onCreate method:

    /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent intent = getIntent();
    if (intent.getData() == null)
        intent.setData(Formulas.CONTENT_URI);

    AutoCompleteTextView searchBar = (AutoCompleteTextView)findViewById(R.id.searchBar);
    Cursor c = getContentResolver().query(getIntent().getData(),new String[] { Formulas.TITLE }, null, null, null);
    SimpleCursorAdapter searchAdapter = 
        new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, c, 
                new String[] { Formulas.TITLE } , new int[] { android.R.id.text1} );
    searchBar.setAdapter(searchAdapter);
}

I did input some sample data in my databaseopenhelper:

        @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE formula ( \n" +
                "_id INTEGER PRIMARY KEY AUTOINCREMENT, \n" +
                "title TEXT NOT NULL, \n" +
                "formula TEXT NOT NULL \n" +
                ");");
        db.execSQL("INSERT INTO formula VALUES ( \n" +
                "null, \"Pythagorean theorium\", \"a^2+b^2=c^2\" \n" +
                "); ");
        db.execSQL("INSERT INTO formula VALUES ( \n" +
                "null, \"Perimeter of a square\", \"l^2 * w^2\" \n" +
                "); ");
        db.execSQL("INSERT INTO formula VALUES ( \n" +
                "null, \"Area of a square\", \"l^4\" \n" +
                "); ");
    }

The problem is where I set the adapter to the AutoCompleteTextView, I expect the values that I inserted using the SQLiteDatabase.execSQL(String) method. But nothing is there? The dropdown box doesn't even show up? I used debugging and found that the Cursor was not null and neither was the adapter or AutoCompleteTextView? What could be the problem? I already defined my own contentprovider.

A: 

The query returned nothing because the content uri was faulty and completely my fault. Here is the relavent thread.

Mohit Deshpande