Android 如何在共享首选项中设置长值?

Android 如何在共享首选项中设置长值?,android,sharedpreferences,Android,Sharedpreferences,我无法将Long值放入共享首选项中。当我放入字符串时工作正常 代码如下: SharedPreferences repeat_rowId = getSharedPreferences("repeat_rowId", 0); SharedPreferences.Editor editor = repeat_rowId.edit(); editor.putLong("rowId", mRowId);// I am getting the Error in this line.. editor.putS

我无法将
Long
值放入共享首选项中。当我放入
字符串时
工作正常

代码如下:

SharedPreferences repeat_rowId = getSharedPreferences("repeat_rowId", 0);
SharedPreferences.Editor editor = repeat_rowId.edit();
editor.putLong("rowId", mRowId);// I am getting the Error in this line..
editor.putString("row_str","ABC");
editor.commit();

如何使用
Long
值?

可能您没有使用Long

Long.parseLong(string);  
如果是字符串,请使用此选项


除此之外,您的LogCat告诉您什么…

这很可能是错误,因为mRowId不是Long类型-当您尝试执行此操作时,该变量存储了什么?或者更具体地说,错误说明了什么?