Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Dev: How do I extract data from the web and use the data in my app?

Tags:

android

I saw this android app called Lyrics App. It provides the lyrics of the song currently played but needs internet connection always. Now, I wanted to make a similar app, that it gets the lyrics from the web for the first time and then saves it to my android device, so that next time a song is played, it'll get the lyrics from the device instead of the web.. no need for constant internet connection.

I've searched already but I can't find the right one for my case. I checked webview, but I think it's just for displaying webcontent, not extracting.

I am new to this, so please bear with me.

like image 381
Jooty Avatar asked Dec 24 '10 00:12

Jooty


People also ask

What are different ways to store data in your Android app?

Internal storage, external storage, shared preferences, database, and shared storage are some of the storage options offered by Android.

Can Android apps access app data?

On devices that run Android 9 (API level 28) or lower, your app can access the app-specific files that belong to other apps, provided that your app has the appropriate storage permissions.

Where are Android app data files stored?

For normal apps, there are stored in internal memory in /data/app. Some of the encrypted apps, the files are stored in /data/app-private. For apps stored in the external memory, files are stored in /mnt/sdcard/Android/data.


1 Answers

Try...

DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://www.someplace.com");
ResponseHandler<String> resHandler = new BasicResponseHandler();
String page = httpClient.execute(httpGet, resHandler);

This can be used to grab the whole webpage as a string of html, i.e., "<html>...</html>"

EDIT: Note, you need to declare the following 'uses-permission' in the android manifest xml file...

<uses-permission android:name="android.permission.INTERNET" />
like image 94
Squonk Avatar answered Oct 01 '22 02:10

Squonk