Loading core/java/android/provider/Downloads.java +27 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,11 @@ package android.provider; import android.net.Uri; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import java.io.File; /** * The Download Manager Loading Loading @@ -1065,5 +1070,27 @@ public final class Downloads { */ public static final int VISIBILITY_HIDDEN = 2; /** * Using a file name, create a title for a download. Then store it in * the database and return it. * * @param context Context for reaching the {@link ContentResolver} so * the database can be updated with the new title. * @param filename Full path to the file. Used to generate a title. * @param id Id of the download, so the new title can be stored in the * database * @return String Newly created title. * @hide */ public static String createTitleFromFilename(Context context, String filename, long id) { if (filename == null) return null; String title = new File(filename).getName(); ContentValues values = new ContentValues(); values.put(COLUMN_TITLE, title); context.getContentResolver().update(ContentUris.withAppendedId( CONTENT_URI, id), values, null, null); return title; } } } Loading
core/java/android/provider/Downloads.java +27 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,11 @@ package android.provider; import android.net.Uri; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import java.io.File; /** * The Download Manager Loading Loading @@ -1065,5 +1070,27 @@ public final class Downloads { */ public static final int VISIBILITY_HIDDEN = 2; /** * Using a file name, create a title for a download. Then store it in * the database and return it. * * @param context Context for reaching the {@link ContentResolver} so * the database can be updated with the new title. * @param filename Full path to the file. Used to generate a title. * @param id Id of the download, so the new title can be stored in the * database * @return String Newly created title. * @hide */ public static String createTitleFromFilename(Context context, String filename, long id) { if (filename == null) return null; String title = new File(filename).getName(); ContentValues values = new ContentValues(); values.put(COLUMN_TITLE, title); context.getContentResolver().update(ContentUris.withAppendedId( CONTENT_URI, id), values, null, null); return title; } } }