Added ApkProvider.get() to return a single apk.
This allows you to specify the Uri of a single apk, and it will return it. Right now it is just used in a test, but hopefully it will be useful in other situations too. I forgot to commit this last time, and didn't review my patch well enough before submitting.
This commit is contained in:
parent
8c6ce67100
commit
de085f7e02
@ -116,6 +116,24 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
Cursor cursor = resolver.query(uri, fields, null, null, null);
|
Cursor cursor = resolver.query(uri, fields, null, null, null);
|
||||||
return cursorToList(cursor);
|
return cursorToList(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Apk get(Context context, Uri uri ) {
|
||||||
|
return get(context, uri, DataColumns.ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Apk get(Context context, Uri uri, String[] fields) {
|
||||||
|
ContentResolver resolver = context.getContentResolver();
|
||||||
|
Cursor cursor = resolver.query(uri, fields, null, null, null);
|
||||||
|
Apk apk = null;
|
||||||
|
if (cursor != null) {
|
||||||
|
if (cursor.getCount() > 0) {
|
||||||
|
cursor.moveToFirst();
|
||||||
|
apk = new Apk(cursor);
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
return apk;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface DataColumns extends BaseColumns {
|
public interface DataColumns extends BaseColumns {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user