Android Data and Access (2)-delphi Xe7 How do I access my app configuration parameters file?

Source: Internet
Author: User

This method is not recommended because the Sharedpreference is an Android method. You want to cross-platform, you can not use on iOS. It is recommended to use INI or XML. Android because read and write the two kinds of files more cumbersome, so launch their own simple sharedpreference.

Back to the topic. On the code:

Note the reference unit:

Uses androidapi.helpers;

1 procedureTform_getparas.getparas;2 varprefs:jsharedpreferences;3 Editor:jsharedpreferences_editor;4 I:integer;5 begin6Prefs: =sharedactivity.getpreferences (TJActivity.JavaClass.MODE_PRIVATE);7Fv_usegname: = jstringtostring (Prefs.getstring (stringtojstring ('Username'), Stringtojstring ("')));8FV_PW: = jstringtostring (Prefs.getstring (stringtojstring ('USERPW'), Stringtojstring ("')));9Fv_serverip: = jstringtostring (Prefs.getstring (stringtojstring ('ServerIP'), Stringtojstring ('127.0.0.1')));Ten    Try OneFv_serverport: = IntToStr (Prefs.getint (stringtojstring ('ServerPort'),8099)); A    except -Fv_serverport: ="'; -    End; the End;

Write Parameters:

1 procedureTform_getparas.writerparas;2 varprefs:jsharedpreferences;3 Editor:jsharedpreferences_editor;4 I:integer;5 begin6Prefs: =sharedactivity.getpreferences (TJActivity.JavaClass.MODE_PRIVATE);7Editor: =Prefs.edit;8Editor.putstring (Stringtojstring ('ServerIP'), stringtojstring (Fv_serverip));9Editor.putstring (Stringtojstring ('Username'), stringtojstring (Fv_usegname));TenEditor.putstring (Stringtojstring ('USERPW'), stringtojstring (FV_PW)); One   Try AI: =Strtoint (fv_serverport); -Editor.putint (Stringtojstring ('ServerPort'), i); -   except theEditor.putstring (Stringtojstring ('ServerPort'), Stringtojstring ('8099')); -   End; -Editor.commit;//apply; - End;

Android Data and Access (2)-delphi Xe7 How do I access my app configuration parameters file?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.