I have an Android app with intent filter for "http". After install the user get "open with" dialog when he press a url in the browser. My question is: If the user chose by mistake "open with x always" and he wants to change his selection to open the url with another app, how can he get the "choose app" dialog again ?
Asked
Active
Viewed 317 times
1 Answers
0
You have to clear the cache of the application.
For clearing cache you have take permission -
<uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>
Call deleteCahce()
to clear cahe
public static void deleteCache(Context context) {
try {
File dir = context.getCacheDir();
deleteDir(dir);
} catch (Exception e) {}
}
public static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
return dir.delete();
} else if(dir!= null && dir.isFile()) {
return dir.delete();
} else {
return false;
}
}
Clear the cache before showing "Open With".

Farman Ali Khan
- 822
- 7
- 24