I have an activity where I write a name that is inserted into the database. In another action, I want to put a ListView that is populated with the names that are in the database, or to add a new item directly when I write it to edittext from the first action. I realized that insertion into the database, but I canβt figure out how to populate this list.
public class Add extends Activity implements OnClickListener{ Button sqlUpdate; EditText sqlName; @Override protected void onCreate(Bundle savedInstanceState) {
}
Here is the database helper:
public class DBhelp { public static final String KEY_ROWID = "_id"; public static final String KEY_NAME = "persons_name"; private static final String DATABASE_NAME = "DBhelpdb"; private static final String DATABASE_TABLE = "peopleTable"; private static final int DATABASE_VERSION = 1; private DbHelper ourHelper; private final Context ourContext; private SQLiteDatabase ourDatabase; private static class DbHelper extends SQLiteOpenHelper{ public DbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION);
And here is the activity in which I want to implement a listview with these elements:
public class Liste extends Activity{ Button btnAdd; @Override protected void onCreate(Bundle savedInstanceState) {
I would be very grateful if you could explain to me how to do this or give me a link with advice or a tutorial that could help me. Thank you very much!
source share