- Android: How store url in string.xml resource file?
- 4 Answers 4
- Storing URL in Android
- 3 Answers 3
- Store URL in a database?
- 3 Answers 3
- Not the answer you’re looking for? Browse other questions tagged android or ask your own question.
- Related
- Hot Network Questions
- Subscribe to RSS
- how to validate a URL / website name in EditText in Android?
- 6 Answers 6
- Short answer
- Long answer
- What is a key store path in Android Studio?
- 2 Answers 2
Android: How store url in string.xml resource file?
I’m trying to store a fully qualified url, with also query params:
but it’s causing a problem because ® is similar to ® entity and android tell me that and html entity is not well written.
I need this because every locale uses a fully different set of url query param.
I tried with [[CDATA[.. ]] but this syntax disliked by xml parser.
4 Answers 4
The problem is not with &req but with & itself. For XML/HTML you would have to use & entity (or & ), but for URLs you should rather URL-encode (see docs) strings, and in that case said & should be replaced with %26 . So your final string should look like:
Store it like this:
Where & is the XML equivelant of the ampersand symbol & .
Percent encoding may do the trick: http://en.wikipedia.org/wiki/Percent-encoding You’ll basically have something like this: www.miosito.net?prova%26reg=bis
You can enclose your url in double quotes, something like :
This is a recommended way to enclose string resources in Android.
Update 1 : Have a look at the following link for more info :
Update 2: @WebnetMobile.com : Correct, indeed 🙂 ‘&’ is being treated a special character by xml and enclosing in quotes doesn’t work. I tried out
www.miosito.net?prova%26reg=bis
and it didn’t work out either. I even tried enclosing it in quotes but still didn’t work. Am I missing something ?
Meanwhile, the following does work :
and then in code :
Resources resources=getResources();
String url=String.format(resources.getString(R.string.my_url),»?»,»&») ;
The ‘%1$s’ and ‘%2$s’ are format specifiers, much like what is used in printf in C. ‘%1$s’ is for strings, ‘%2$d’ is for decimal numbers and so on.
Источник
Storing URL in Android
I am trying to access my mysql database through PHP. I have the URL and things are working fine but my question is: which is the best way to store the URL in the project? I thought Strings.xml is safe to store all kinds of URL but then realized strings.xml can be decompiled to get the URl easily.
What / where is the best way to store the URL in my android?
3 Answers 3
Everything is useless, URL can be easily seen with proxy even if you use proguard or string encryption or HTTPS. You can’t hide it. You only can add authentication to protect data.
I don’t see much advantage in hiding/obfuscating URLs as urls could easily be seen through network tools. but
So, If you want that some one can not easily decompile and see any string you are saving, you can obfuscate the code. Some options include
- Use dexguard https://www.guardsquare.com/dexguard. It is made by the same developer (Eric) who also developed proguard.
1.Store them as String constants public static final in a separate class if they are not going to change.
- Store them in android:tag
Unlike IDs, tags are not used to identify views. Tags are essentially an extra piece of information that can be associated with a view. They are most often used as a convenience to store data related to views in the views themselves rather than by putting them in a separate structure.
and get using view.getTag()
Note: The above are the few ways of storing URLs in android but from security perspective as I commented below you should look to secure your APIs on server side instead of worrying about hiding on client side as everything can be decompiled.
Источник
Store URL in a database?
What is the best way to store URL that will be used in the application to static?
For example i want to save URL for a feed that are called each time the application is opened.
What would be the best way?
An example would be great!
Here is my Feed.class
3 Answers 3
For Storing in a SQLite DB the best way to do it is by creating a class that extends SQLiteOpenHelper super class.In this class you will define the functions to insert in the database, to delete, create tabels and so on. One easiest approach is-if you know the structure of your database(if u store only URLs in one tabel) you can create the DB using an SQLiteBrowser.If you are interested I can give you the code and the link to the browser.Good luck!!
Is your question «How do I use a database to store data?» (in which case you really confuse the issue with such unnecessary detail) or are you just asking «How do I store a URL?».
If the latter. a URL is just text, so simply store it as a text string.
If you just need to store a url, you don’t need a database.
Using Activity.getSharedPreferences() or Context.openFileInput(filename) / Context.openFileOutput(filename, mode) should be fine. You will just have to store and retrieve your url using some short file-oriented code.
Not the answer you’re looking for? Browse other questions tagged android or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.12.3.40888
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Источник
how to validate a URL / website name in EditText in Android?
I want to take input, a URL or just a website name like, www.google.com from EditText in Android and on user click on the Button to submit or when the EditText looses the focus the URL should be validated, like it is in the format «www.anyURL.com«.
How can I do this? Is there any inbuilt functionality available in android?
6 Answers 6
Short answer
Use WEB_URL pattern in Patterns Class
It will return True if URL is valid and false if URL is invalid.
Long answer
As of Android API level 8 there is a WEB_URL pattern. Quoting the source, it «match[es] most part of RFC 3987». If you target a lower API level you could simply copy the pattern from the source and include it in your application. I assume you know how to use patterns and matchers, so I’m not going into more details here.
Also the class URLUtil provides some useful methods, e.g:
The descriptions of the methods are not very elaborate, therefore you are probably best of looking at the source and figuring out which one fits your purpose best.
As for when to trigger the validation check, there are multiple possibilities: you could use the EditText callback functions
or use a TextWatcher, which I think would be better.
DON’T USE URLUtil to validate the URL as below.
Источник
What is a key store path in Android Studio?
I just created my first game using Buildbox and I am trying to upload it to the Google Play Store. Apparently, I have to use Android Studio to turn the game file into an APK. So far, I know how to open it and select «Generate signed APK» or something along those lines, but then I am given a screen like this. I have virtually no prior knowledge of any of this, so am I supposed to create a new key store path? Do I already have one? How do I do it?
Any tips are appreciated 🙂
2 Answers 2
Key Store Path is the location where your keystore should be created.
If you are creating an apk for first time to release in play store, you have to select ‘Create New. ‘ ketstore path, where in which you will be promoted to a new window where you can fill in the details:
KeyStore path : select a path in your system (Create a path in any drive eg: *F:\AndroidKeys*)give a name to your key(eg:game).save in here with the specific name for your project (F:\AndroidKeys\game.jks).
Password**: Give some new password and confirm it(Don’t forget).
Alias : Enter an identifying name for your key.
Password : Create and confirm a secure password for your key. This should be different from the password you chose for your keystore.
Validity: select time period for validity of key.
Certificate: Enter some information about yourself or organization (like name. ). Done with new key generation.
Now on the screen you mentioned select the path, key store password,key alias,key password(will be auto filled at first key generation). click next — select build variants(debug or release) release in your case, select the signature versions— finish .
You can find your release apk in app\release folder of your project.
Источник