1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-21 07:51:46 +02:00

Make meta URI use MatrixCursor to provide data

This commit is contained in:
Erik Johansson
2018-09-30 20:31:08 +02:00
parent ee00d9ef69
commit bb0f3f455a
2 changed files with 5 additions and 8 deletions

View File

@@ -607,11 +607,6 @@ public class OpenScale {
}
}
public Cursor getMetaCursor(int apiVersion, int versionCode) {
return appDB.query("SELECT ? AS apiVersion, ? as versionCode",
new Object[]{apiVersion, versionCode});
}
// As getScaleUserList(), but as a Cursor for export via a Content Provider.
public Cursor getScaleUserListCursor() {
return userDAO.selectAll();

View File

@@ -20,6 +20,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import com.health.openscale.BuildConfig;
@@ -37,7 +38,8 @@ import com.health.openscale.core.OpenScale;
*
* The following URIs are supported:
* <ul>
* <li><code>content://com.health.openscale.provider/user</code>: list all users.</li>
* <li><code>content://com.health.openscale.provider/meta</code>: API and openScale version.</li>
* <li><code>content://com.health.openscale.provider/users</code>: list all users.</li>
* <li><code>content://com.health.openscale.provider/measurements/$ID</code>:
* retrieve all measurements for the supplied user ID.</li>
* </ul>
@@ -88,8 +90,8 @@ public class ScaleDatabaseProvider extends android.content.ContentProvider {
switch (uriMatcher.match(uri)) {
case MATCH_TYPE_META:
cursor = OpenScale.getInstance().getMetaCursor(
API_VERSION, BuildConfig.VERSION_CODE);
cursor = new MatrixCursor(new String[]{"apiVersion", "versionCode"}, 1);
((MatrixCursor) cursor).addRow(new Object[]{API_VERSION, BuildConfig.VERSION_CODE});
break;
case MATCH_TYPE_USER_LIST: