duzzell 0 Posted yesterday at 08:50 AM I'm running Delphi 12.1 on Windows 10, to build an FMX app. I'm using TMS Aurelius v5.19 against a SQLite database via a FireDAC driver. I'm having trouble reading strings from the database on Android 32 and 64. TLocalDefault has the following structure: TLocalDefault = class(TLocalDBObject) private [Column(STRCreatedAt, [TColumnProp.Required])] fCreatedAt: TDateTime; [Column(STRID, [TColumnProp.NoUpdate])] fID: String; [Column(STRModifiedAt, [])] fModifiedAt: TDateTime; [Column(STRKeyValue, [TColumnProp.Unique], KShortStringLength)] fKeyValue: String; [Column(STRIsPermanent, [])] fIsPermanent: integer; [Column(STRStringValue, [], KShortStringLength)] fStringValue: String; function GetIsPermanent: Boolean; function GetKeyValue: String; function GetStringValue: string; procedure SetCreatedAt(const Value: TDateTime); procedure SetIsPermanent(const Value: Boolean); procedure SetKeyValue(const Value: String); procedure SetStringValue(const Value: string); public constructor Create(const aKey, aStringValue: String; const aIsPermanent: Boolean = False); overload; class procedure SetUserDefault(const KeyValue, StringValue: string; aIsPerm: Boolean = False); class procedure SignOut; class function StringValueForKey(const KeyValue: string): string; property IsPermanent: Boolean read GetIsPermanent write SetIsPermanent; property KeyValue: String read GetKeyValue write SetKeyValue; property StringValue: String read GetStringValue write SetStringValue; published property CreatedAt: TDateTime read fCreatedAt write SetCreatedAt; property ID: String read fID; property ModifiedAt: TDateTime read fModifiedAt write fModifiedAt; end; I use the following function to retrieve string values: class function TLocalDefault.StringValueForKey(const KeyValue: string): string; var lUserDefault: TLocalDefault; begin lUserDefault := ObjectManager.Find<TLocalDefault>. Where(Linq['KeyValue'] = KeyValue).UniqueResult; if Assigned(lUserDefault) then result := lUserDefault.StringValue else result := ''; end; This works on Windows, ios, macos and Linux. On Android 32 and 64 this function always returns an empty string. In the Android debugger, lUserDefault.StringValue evaluates to the expected string value. But after the assignment to result, Result still evaluates to ''. The Local Variables list also shows '' for Result. However, the entry for Result has a caret next to it. When I click the caret, a second line appears with a Name of &Result and a Value of the expected string value for this TLocalDefault. The other platforms do not display the caret. Is this due to string handling on Android? I've tried casting lUserDefault.StringValue to a string, assigning lUserDefault.StringValue to a temporary string variable and then to Result, capturing the TCriterion returned by Find and calling UniqueResult on it, assigning lUserDefault.StringValue to the function name instead of Result, and assigning &Result to Result. I've also deleted and reinstalled the Android SDK, NDK and Java. All have failed to give me the StringValue. Any ideas about what may be going on, or how I shoule be doing this? Thanks Share this post Link to post
Cristian Peța 107 Posted yesterday at 12:36 PM 3 hours ago, duzzell said: lUserDefault.StringValue evaluates to the expected string value. That means that TLocalDefault.GetStringValue returns expected string? Result in GetStringValue is what you expect? Share this post Link to post
duzzell 0 Posted yesterday at 01:39 PM If I put a breakpoint on the if statement and then evaluate lUserDefault.getStringValue at that point, yes, the correct value is returned. I have not tried returning the TLocalDefault object to the caller instead of the string value. Share this post Link to post