How to encode the filename parameter of Content-Disposition header in HTTP?

I know this is an old post but it is still very relevant. I have found that modern browsers support rfc5987, which allows utf-8 encoding, percentage encoded (url-encoded). Then Naïve file.txt becomes: Content-Disposition: attachment; filename*=UTF-8”Na%C3%AFve%20file.txt Safari (5) does not support this. Instead you should use the Safari standard of writing the file name directly in …

Read more

How to use SharedPreferences in Android to store, fetch and edit values [closed]

To obtain shared preferences, use the following method In your activity: SharedPreferences prefs = this.getSharedPreferences( “com.example.app”, Context.MODE_PRIVATE); To read preferences: String dateTimeKey = “com.example.app.datetime”; // use a default value using new Date() long l = prefs.getLong(dateTimeKey, new Date().getTime()); To edit and save preferences Date dt = getSomeDate(); prefs.edit().putLong(dateTimeKey, dt.getTime()).apply(); The android sdk’s sample directory contains …

Read more