Вот добавление в таблицу
String tmp = editText.getText().toString();
dbHelper = new DbHelper(view.getContext());
db = dbHelper.getWritableDatabase();
db.execSQL("INSERT INTO " + DbHelper.TABLE_USERS +" ( "+ DbHelper.KEY_NAME + " ) VALUES ('"+ tmp + "');");
db.close();
Вот чтение из этой таблицы в listView в другом фрагменте
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_result, container, false);
listView = (ListView) view.findViewById(R.id.listRes);
dbHelper = new DbHelper(view.getContext());
db = dbHelper.getReadableDatabase();
int i = 0;
Cursor c = db.rawQuery("Select * FROM " + DbHelper.TABLE_USERS, null);
if(c!=null&&c. moveToFirst()){
do{
String name = c.getString(c.getColumnIndexOrThrow (DbHelper.KEY_NAME)) ;
informations[i] = name;
i++;
}while(c.moveToNext());
}
ArrayAdapter<String> adapter = new ArrayAdapter<>(view.getContext(), android.R.layout.simple_list_item_1, informations);
listView.setAdapter(adapter);
db.close();
return view;