Je veux obtenir les lignes qui ont été ajoutées au cours des dernières semaines.Obtenir des lignes avec 'date_added' entre deux dates ne fonctionne pas
Voici mon code actuel:
private static Cursor makeRecentlyAddedSongsCursor(Context context) {
String[] sProjection = new String[] {MediaStore.Audio.Media._ID, MediaStore.Audio.Media.DATE_ADDED};
String MIN_DATE = String.format("dd/MM/yyyy", new Date().getTime() - ((long) PreferenceUtility.getRecentlyAddedTimespan(context) * 7L * 24L * 60L * 60L * 1000L));
String CURRENT_DATE = String.format("dd/MM/yyyy", new Date().getTime());
String sSelection = MediaStore.Audio.Media.DATE_ADDED + Constants.Database.BETWEEN; //String BETWEEN = " BETWEEN ? AND ?";
String[] sSelectionArgs = {MIN_DATE, CURRENT_DATE};
return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, sProjection, sSelection, sSelectionArgs, MediaStore.Audio.Media.DATE_ADDED + Constants.Database.SORT_DESCENDING);
}
L'erreur doit être dans l'argument de sélection, parce que si je le laisse loin, toutes les chansons sont montrées, triées correctement.
J'espère que vous pouvez m'aider!
ne fonctionne pas du tout –
En effet, il en raison du format DATE_ADDED ... Il est un long. J'ai mis à jour ma réponse –