Fix android LocalStorage return null for empty string value

This commit is contained in:
pandamicro 2016-05-11 11:57:54 +08:00
parent ac2b336eb6
commit 1cbbde5d8b
2 changed files with 5 additions and 1 deletions

View File

@ -89,7 +89,7 @@ public class Cocos2dxLocalStorage {
} catch (Exception e) {
e.printStackTrace();
}
return ret == null ? "" : ret;
return ret;
}
public static void removeItem(String key) {

View File

@ -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);