Reputation: 5258
I want to share and receive data at some point from one application to another application, what's the best way to do?
I see content provider
is used with database but I have only few strings to share to another applications. I have data stored in
SHARED PREFERENCES, which other application needs to access and vice-versa.
Please provide suggestions.
TIA.
Upvotes: 1
Views: 310
Reputation: 6107
You can use MatrixCursor.You can populate MatrixCursor
with data. From official doc
A mutable cursor implementation backed by an array of Objects. Use newRow() to add rows. Automatically expands internal capacity as needed.
newRow()
addRow()
method will help you to add columnValues
Here is sample code
try (MatrixCursor cursor = new MatrixCursor(new String[]{"id", "title"})) {
cursor.addRow(new String[] { "1", "Book 1" });
cursor.addRow(new String[] { "2", "Book 2" });
cursor.newRow()
.add("id", "3")
.add("title", "Book 3");
} catch (Exception ignored) {
}
Upvotes: 0