mirror of https://github.com/axmolengine/axmol.git
Fix android LocalStorage return null for empty string value
This commit is contained in:
parent
ac2b336eb6
commit
1cbbde5d8b
|
@ -89,7 +89,7 @@ public class Cocos2dxLocalStorage {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret == null ? "" : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void removeItem(String key) {
|
||||
|
|
|
@ -94,6 +94,10 @@ bool localStorageGetItem( const std::string& key, std::string *outItem )
|
|||
{
|
||||
jstring jkey = t.env->NewStringUTF(key.c_str());
|
||||
jstring jret = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, jkey);
|
||||
if (jret == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
outItem->assign(JniHelper::jstring2string(jret));
|
||||
t.env->DeleteLocalRef(jret);
|
||||
t.env->DeleteLocalRef(jkey);
|
||||
|
|
Loading…
Reference in New Issue