Code example for File

Methods: delete, deleteOnExit, exists

0
    } 
 
    static void deleteWidgetState(Context context, int widgetId) {
        File file = context.getSharedPrefsFile(
                String.format("widgetState-%d", widgetId));
        if (file.exists()) {
            if (!file.delete()) {
                file.deleteOnExit();
            } 
        } 
    } 
 
    static void changeFolder(Context context, Intent intent) {
        int wid = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
        long fid = intent.getLongExtra(Bookmarks._ID, -1);
        if (wid >= 0 && fid >= 0) {
            SharedPreferences prefs = getWidgetState(context, wid);
            prefs.edit().putLong(STATE_CURRENT_FOLDER, fid).commit();
            AppWidgetManager.getInstance(context)
                    .notifyAppWidgetViewDataChanged(wid, R.id.bookmarks_list);
        }