Ejemplo n.º 1
0
 public void insert(Uri url, MusicInfoBean music) {
   ContentValues values = new ContentValues();
   values.put(DB_Constance.Table_musicInfo.COLUMN_NAME, music.getMusicName());
   values.put(DB_Constance.Table_musicInfo.COLUMN_PATH, music.getMusicPath());
   values.put(DB_Constance.Table_musicInfo.COLUMN_COMPOSER, music.getMusicArtist());
   values.put(DB_Constance.Table_musicInfo.COLUMN_IMG, music.getMusicImage());
   values.put(DB_Constance.Table_musicInfo.COLUMN_LYRIC, music.getNusicLyric());
   resolver.insert(url, values);
 }
Ejemplo n.º 2
0
  public void scanFile(File file) {
    File[] listFile = file.listFiles();

    if (listFile != null) {
      for (int i = 0; i < listFile.length; i++) {
        File item = listFile[i];
        if (item.isDirectory()) {
          scanFile(item);
        } else {
          if (item.getName().endsWith("mp3")) {
            MusicInfoBean music = new MusicInfoBean();
            String name = item.getName();
            music.setMusicName(name.substring(0, name.lastIndexOf(".mp3")));
            music.setMusicArtist("unknown");
            music.setMusicPath(item.getAbsolutePath());
            // music.setMusicImage(R.drawable.pc1);

            new Helper().insert(Provider.URI_MUSIC_INFO, music);
          }
        }
      }
    }
  }