0

I am trying to connect to a linkUrl in the code snippet below, then get content from it which is suppose to be in text format and finally save that content in sqlite database using the variable*(linkData)*.

Someone help me with how can carry out those steps in my android app.

Thanks in advance.

for (int i = 0; i < li.size(); i++) {

            /* These are the values that will be collected */
            String title;
            String date;
            String imageUrl;
            String linkUrl;
            String linkData;

            // Extract the value for the keys called "post-title", "date", "post-footer-author",
            // "img", "abs:src", "a" and "href".
            title = li.get(i).getElementsByClass("post-title").text();
            date = li.get(i).getElementsByClass("date").text();
            imageUrl = li.get(i).getElementsByTag("img").attr("abs:src");
            **linkUrl = li.get(i).getElementsByTag("a").attr("abs:href");**

            **linkData = ??????;**

            ContentValues newsValues = new ContentValues();
            newsValues.put(NewsContract.LatestNewsEntry.COLUMN_TITLE, title);
            newsValues.put(NewsContract.LatestNewsEntry.COLUMN_DATE, date);
            newsValues.put(NewsContract.LatestNewsEntry.COLUMN_IMAGE, imageUrl);
            newsValues.put(NewsContract.LatestNewsEntry.COLUMN_LINK, linkUrl);
            newsValues.put(NewsContract.LatestNewsEntry.COLUMN_DATA, linkData);

            newsContentValues[i] = newsValues;
        }
mtondolo
  • 1
  • 4
  • 1
    In what format do you expect the data to be? What is the structure of the data you are expecting, we have to know these just to be able to help you. – Clement Osei Tano Nov 08 '18 at 08:40
  • I expect the data should be in text format. Please see link below of sample link to extract content from: http://www.comesa.int/the-8th-hydropower-for-today-forum-starts-on-nov-6/ – mtondolo Nov 08 '18 at 09:15
  • What you are trying to do is called website scraping as described [here](https://stackoverflow.com/questions/34469737/how-do-i-perform-web-scraping-in-android#34469993). Read more about it. – Clement Osei Tano Nov 08 '18 at 13:24

0 Answers0