Jump to content
footboyedit

dar o valor da shared preference a uma connection string

Recommended Posts

footboyedit

boas, como eu consigo dar o valor da shared preference a uma connection string?

ex.

ConnURL = "jdbc:jtds:sqlserver://" + ip + ";"

+ "databaseName=" + db + ";user=" + un + ";password="

+ password + ";";

por exemplo eu quero que substitua o ip pelo valor que eu guardo na edittext noutra activity através de shared preference..

obrigado :)

Share this post


Link to post
Share on other sites
iRiKi

Nao seria mais facil guardares o valor numa string em strings.xml?

Por exemplo, seria algo do genero:

<string name="connectiong_string">jdbc:jtds:sqlserver://%1$s;databaseName=%2$s;user=%3$s;password=%4$s;</string>

Ou entao, crias uma constante com a formatacao pretendida, substituis os campos e depois guardas a string completa na Shared Preferences. Ou guardas so os valores e sempre que iniciares a aplicacao constrois a connectiong string completa. Cuidado é ao armazenares a informacao em texto simples.. isso é demasiado facil de ser lido externamente.

Cumps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.