diff --git a/src/android/Context.cxx b/src/android/Context.cxx index f86f26bdf..ebeda6ec4 100644 --- a/src/android/Context.cxx +++ b/src/android/Context.cxx @@ -44,13 +44,12 @@ Context::Initialise(JNIEnv *env) noexcept } AllocatedPath -Context::GetExternalFilesDir(JNIEnv *env, const char *_type) noexcept +Context::GetExternalFilesDir(JNIEnv *env, const char *type) noexcept { assert(_type != nullptr); - Java::String type{env, _type}; - - jobject file = env->CallObjectMethod(Get(), getExternalFilesDir_method, type.Get()); + jobject file = env->CallObjectMethod(Get(), getExternalFilesDir_method, + Java::String::Optional(env, type).Get()); if (Java::DiscardException(env) || file == nullptr) return nullptr; diff --git a/src/android/Context.hxx b/src/android/Context.hxx index b771bc69a..ae451e230 100644 --- a/src/android/Context.hxx +++ b/src/android/Context.hxx @@ -36,9 +36,12 @@ public: Context(JNIEnv *env, jobject obj) noexcept :Java::GlobalObject(env, obj) {} + /** + * @param type the subdirectory name; may be nullptr + */ [[gnu::pure]] AllocatedPath GetExternalFilesDir(JNIEnv *env, - const char *type) noexcept; + const char *type=nullptr) noexcept; [[gnu::pure]] AllocatedPath GetCacheDir(JNIEnv *env) const noexcept;