4

I am making an application that asks the user for userid, appends the userid to a static HTTP link to retrieve the user's daily schedule info file that has a .ical (calendar) extension.

I need to read the data from file, format in new UI and representing some useful data on an Android device.

My query is can I access a static HTTP link behind the scenes? And when I use the same link on desktop browser, it asks user to save the file — how can I do this on a mobile? Do I need to read the data and save it somewhere or I can save the .ical file and read from it?

Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
rob
  • 5,771
  • 4
  • 23
  • 26
  • Hi Rob, there are a number of other questions under the [android] tag on this site about retrieving HTTP data. This sounds like a straightforward task. As for parsing the data, you can either save the file temporarily to your Android app's local storage and only read and parse it at runtime, or you can parse it and save the data directly to an SQL database on the Android device. – Christopher Orr Jan 23 '10 at 23:56
  • Hi Christopher, see the problem is the file i am trying to read that is not static thats the calendar file , different for every user at anytime. Might be its simple but as i am new to this so i have some confusions about it. I read about SqLite and had same plan to save data in it and retrieve but The file is icalfile.ics , i need to specify the format to open it for example excel or notepad on desktop. how can i handle it in mobile. it there any way to read icalfile.ics directly? Thanks – rob Jan 24 '10 at 00:10

1 Answers1

4

Android devices generally cannot handle iCalendar-formatted files (.ics) — there is no way to just "open" such a file and have the information displayed. You would have to write some code (or use a library such as iCal4j) to parse the information in the calendar file.

Based on your question and comments, you need to break this into a few parts:

  1. Get the user's ID entered in the UI
    • String userId = ((EditText) findById(R.id.user_id)).getText.toString();
  2. Generate the user's unique calendar URL
    • static final String CALENDAR_BASE = "http://example.com/cal/";
      String escapedUserId = URLEncoder.encode(userId, "UTF-8");
      String url = CALENDAR_BASE + escapedUserId +"/events.ics";
  3. Retrieve the calendar file over HTTP
  4. Save the file locally
  5. Display the calendar data to the user
    • Read the file from disk that you saved directly from the web
    • Parse the data with iCal4j and display in whatever UI format you like

You can search Stack Overflow or post a more particular question regarding any of the individual parts if you're unsure or need some more specific info. :)

Community
  • 1
  • 1
Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
  • Hi Christopher, I tried to make the application but while making it I have found some more issues. The application i am working on is already there for the desktop users that allow users to login and view the information. As you know that the ical file generated as it gets the data. I cannot have access to the data information of that system due to security reasons, all I can do it i can use a link along with the user id that is unique for every user. When i use link on desktop browser it gives me ical file with the name of user id. – rob Jan 28 '10 at 00:14
  • And as I mentioned earlier that i can open the file in notepad or excel format by selecting open with. The ical file is raw file from server having information of particular user, html tags and some raw info. The size of the file is approx in 50 KB. – rob Jan 28 '10 at 00:19
  • Do i need to give the name to file? Or I can save it to memory with the same name as it is generated. – rob Jan 28 '10 at 00:28
  • The file name does not matter. You can use any file name you like. Probably just the user ID would be a good idea, so you don't end up with many files in local storage; just one, most-recent file for the user. – Christopher Orr Jan 28 '10 at 09:18
  • @ChristopherOrr is it recommended to generate the ics file on the server and send it over via API to be read and parsed by clients of we should generate it on the client side based on the event data params? –  Oct 03 '19 at 14:15