Ниже приведен код Java.
Код: Выделить всё
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
insertNote("New note");
Cursor cursor = getContentResolver().query(NotesProvider.CONTENT_URI,
NotesTable.COLUMNS_LIST, null,null, null, null);
String[] from = {NotesTable.NOTE_TEXT};
int[] to = {android.R.id.text1};
CursorAdapter cursorAdapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_1, cursor, from, to, 0);
ListView listView = findViewById(R.id.list_view);
listView.setAdapter(cursorAdapter);
}
private void insertNote(String noteText) {
ContentValues values = new ContentValues();
values.put(NotesTable.NOTE_CREATED, noteText);
Uri noteUri = getContentResolver().insert(NotesProvider.CONTENT_URI, values);
Log.d("MainActivityDebug", "Inserted note " + noteUri.getLastPathSegment());
}
Код: Выделить всё
Код: Выделить всё
@color/primary
@color/primary_dark
@color/accent
@color/text_color_primary
[img]https://i.stack.imgur .com/9NEnT.png[/img]
Наконец, я хочу, чтобы опытный разработчик, который долгое время занимался разработкой для Android, возможно, до 2015 года, сказал мне, не слишком ли старомодно использовать Поставщик контента для управления операциями с базой данных и то, что мне следует использовать. Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/781 ... ext-hidden