In my current android project, I am trying associate a ListView to a returned query from my database (the method which handle this query in my dao class will be findAll
).
I have this code:
public class HelloActivity extends ListActivity {
UsuarioDao usuario = new UsuarioDao();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_list_activity_view);
Cursor mCursor = this.getContentResolver().query(???, null, null, null, null);
startManagingCursor(mCursor);
ListAdapter adapter = new SimpleCursorAdapter(
this,
android.R.layout.two_line_list_item,
mCursor,
new String[] {usuario.nome, usuario.sobrenome},
new int[] {R.id.text1, R.id.text2});
setListAdapter(adapter);
}
}
I am looking for the correct URI which fills the first parameter in the query(...) method above.
Anyone can give a hint in how to do this? Also, what should be the returned from findAll? My first idea was return a Cursor. Is this correct and would be useful in this case?
this.getContentResolver().query is used when you have content provider... In your example
???
should we the URI which is defined by your content provider.. nothing to do with DAO concept.DAO concept is normally used when you have an additional Data access layer defined that will have APIs defined by you to handle each kind of data.