mirror of https://github.com/axmolengine/axmol.git
Implement localStorage.clear on Android
This commit is contained in:
parent
3190d0e5fb
commit
8577055d5a
|
@ -101,6 +101,15 @@ public class Cocos2dxLocalStorage {
|
|||
}
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
try {
|
||||
String sql = "delete from "+TABLE_NAME;
|
||||
mDatabase.execSQL(sql);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This creates/opens the database.
|
||||
|
|
|
@ -147,4 +147,16 @@ void localStorageRemoveItem( const std::string& key )
|
|||
|
||||
}
|
||||
|
||||
/** removes all items from the LS */
|
||||
void localStorageClear()
|
||||
{
|
||||
assert( _initialized );
|
||||
JniMethodInfo t;
|
||||
|
||||
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxLocalStorage", "clear", "()V")) {
|
||||
t.env->CallStaticVoidMethod(t.classID, t.methodID);
|
||||
t.env->DeleteLocalRef(t.classID);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
|
Loading…
Reference in New Issue