I have an android app which pulls text data from a SQLite database (located in /assets/ folder). The problem is, if i store a hyperlink, say http://example.com in my SQLite database, it is rendered as normal text in my android app. It's not clickable. How can i pull a clickable hyperlink from SQLite database and show it in my app?
If it's a TextView, include the following in the definition:
android:autoLink="web"
Use Linkify for transforming text containing links into text with clickable links.
The URL stored in your SQLite DB is just text like you mentioned. If I understand your question what you want is to trigger the browser and open the URL you have stored in your DB?
If so, you can simply query the URL from the SQLite DB and do the following to display it in the default browser.
String url = 'http://example.com'; // Get it from your DB as you are doing now.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
Related
I have a flutter application and I am using firestore database, but when I add a URL in the description field and run my application, this URL is not clickable, it stays like a text, just like the rest of the description
How can I make it work the way I need it?
It's probably a better idea to store the url on the database as a separate attribute. You can then decide when and where to display it. If you keep it in the description text then you have to search for and extract it.
I am trying to create an app that displays a list of pdf files, and then load the pdf file in a new browser tab / android activity.
The idea is the user will click a button "Lectures" and then will be shown the list of lectures, clicking on any list item will load the specific pdf file.
I currently have a node js mysql back end, for user login and routes to other pages, which is followed up with both a handlebars and android front end.
I am struggling to understand how I can store pdf files so they can be called based on what the user clicks, I want to store the pdf files on a server rather than within my application and then call them when required.
I have seen a method using ejs view engine to render list of files in public folder, which then allows you to do this, but this entails storing pdfs within the application, alternatively I can host the files with my web hosting, still need to figure out how to load them based on user action.
Would appreciate any direction or solution!
Thanks in advance
Mohamed V
Without knowing how you have the DB set I will talk more along the lines of how you would do this and then modify as needed. In most cases you would probably want to use an object store to store the PDF files. This will allow for access on any application.
Your DB should contain a file name of the PDF file, as an example, lets say you table for 'files' is as such
id, filename, name, extension, courceID
Here you would have the filename maybe the extension type and a refrenceID
Next, in your response callback, you simply return the query for the files, for example let say you run a query like SELECT filename, name WHERE courceID = '12345'
You then return this to the view, if its ejs then you would just pass the object and do something like
<% for ( in in files ) {%>
<div><a href="url-to-object-store/<%-files[i].filename%>"><%-files[i].filename%>
<%}%>
I am currently working on an app, where users enter data in given editText fields for one row and add the data to database.
In case of multiple rows (e.g. 50) to add, I want to allow a user to supply data through text files in specific format with delimeters.
How do I select the file or get file path of that text file supplied by the user
and then use it in my app to add the data to database?
How can I read a text file from the SD card in Android?
How to read text file in Android?
Android read text raw resource file
check these answers for how to load file to your application. Regarding saving inputs to database you can use classic for loop and go through every row and save it to database
I am new to Android app development, I have a simple app which works on WebView to open a website. I want to add "bookmark this webpage" option in my app but I don't know how to proceed.
You can add any button to your app. Or if you are using Toolbar you can add bookmark button to your options and you can save the page url to Sqllite database or any other storage. There are many other ways also.
you can have a look at the following links-
First- Second-
I hope this would help you.
Well you can create a class for that extends SQLLiteOpenHleper. This provides functionality for accessing sqllite database-
You can refer to this and this link for SQlLite..
And you can create a query for creating a table having columns like id, bookmark name and bookmark url.
You can also add some functions for setting name and url, getting name and urls etc.
I hope you find this helpful.
I am newbie in creating android app. I have created a database using xammp and a simple login layout using eclipse. Now I want to connect my login page and the database I created so that when the user enters his/her username and password it will then open the main menu of the application. I am hoping for someone who could help me on how to do this. Thanks in advance.
Try this code .....it will help u
data = openOrCreateDatabase(
"AutoProfiles.db"
, SQLiteDatabase.CREATE_IF_NECESSARY
, null
);
data.setVersion(1);
data.setLocale(Locale.getDefault());
data.setLockingEnabled(true);
final String CREATE_TABLE_LOCATIONS =
"CREATE TABLE IF NOT EXISTS tables ("
+ "name TEXT)";
data.execSQL(CREATE_TABLE_LOCATIONS);
YOur question is a bit confusing... Where does the database get into the Picture. Is the database used to store login information to determine which user is currently logged in?
If this is the case:
Retrieve login information, look through database for corresponding data.
Start new intent and different class with main menu layout.
Link the information in your database to your main menu
I am actually working on a similar project with my application. Here is a simple tutorial that has helped me alot with my project. It explains alot about how a database works in android using eclipse and how to set one up, add, remove, update and get data from that database then.
http://www.smashingmagazine.com/2011/03/28/get-started-developing-for-android-with-eclipse-reloaded/
Hope it helps you as much as it helped me
If you want to connect to a Mysql database you may need to use webservice such as PHP .
Here is how you do it :
You create a Mysql database
You create a PHP file which connects to database and does the data fetching and stuff
Using an AsyncTask use URL methods to acess the remote PHP file
Analyse the return result
The PHP file can either take GET or POST arguments
Example Snippet :
URL url = new URL("http://127.0.0.1/project/check_reg.php?uname="+email.getText().toString()+"&pwd="+password.getText().toString());
URLConnection urlcon = url.openConnection();
BufferedReader bf = new BufferedReader(new InputStreamReader(urlcon.getInputStream()));
String xresponse = bf.readLine();