Thank you for your interest. 

after I renamed a folder. I did re-scanning by sending broadcast intent as 
below. 

             Context applicationContext = MyApplication.*getInstance*
().getApplicationContext();

             applicationContext.sendBroadcast(*new* Intent(Intent.*
ACTION_MEDIA_SCANNER_SCAN_FILE*, 

and then, delete former folder name in database as below. 

*public* *boolean* deleteFolder(String folderPath){

 

             *boolean* isSuccessful = *false*;

             Cursor cursor = *null*;

             String selection;

             

             DELETE_FOLDER : {

                    //1. Get folder '_id' list.(with duplicated one).

                    ArrayList<Integer> folderIdList = *new*ArrayList<Integer>();

                    

               String[] projection = {

                            FileSchema.Columns.*_ID*

               };

                    selection = FileSchema.Columns.*DATA* + " = \"" + 
folderPath + "\"";                

                    cursor = SqliteWrapper.*query*(getContext(), 
getContentResolver(), FileSchema.*getContentUri*("external"), projection, 
selection, *null*, *null*);

                    *if*(cursor != *null* && cursor.moveToFirst() && 
cursor.getCount() > 0){

              *int* dataIndex = cursor.getColumnIndex(FileSchema.Columns.*
_ID*);

               *do* {

                       folderIdList.add(cursor.getInt(dataIndex));

               } *while* ( cursor.moveToNext() );

                           cursor.close();

                    } *else* {

                           isSuccessful = *false*;

                           *break* DELETE_FOLDER;

                    }

                    

                    //2. Delete folders in DB.

                    *while* ( folderIdList.isEmpty() == *false* ) {

               *int* folderId = folderIdList.remove(0);

                     *int* numberOfDeleted = 
SqliteWrapper.*delete*(getContext(), 
getContentResolver(), FileSchema.*getContentUri*("external"), "_id=\""
+Integer.*toString*(folderId)+"\"", *null*);

                     *if* (numberOfDeleted < 0) {

                            isSuccessful = *false*;

                            *break* DELETE_FOLDER;

                     }

              }

                    //3. Delete files in DB.               

                    selection = FileSchema.Columns.*DATA* + " LIKE \"" + 
folderPath + "/%\"";

                    *int* numberOfDeleted = 
SqliteWrapper.*delete*(getContext(), 
getContentResolver(), FileSchema.*getContentUri*("external"), selection, *
null*);

                    *if*(numberOfDeleted < 0){

                           isSuccessful = *false*;

                           *break* DELETE_FOLDER;

                    }

                    

                    //4. Success!

                    isSuccessful = *true*;

                    *break* DELETE_FOLDER;

             }

             

             *return* isSuccessful;

    }



On Wednesday, July 4, 2012 1:58:22 AM UTC+9, Mark Murphy (a Commons Guy) 
wrote:
>
> How did you do the "re-scanning"? 
>
> On Tue, Jul 3, 2012 at 12:53 PM, Hyuck <[email protected]> wrote: 
> > Hi All, 
> > 
> > I have develop a kind of file manager app. recently, I have met a 
> strange 
> > behavior of media scanner. 
> > There was a folder(A) with some media files in it. and I renamed the 
> folder 
> > name to B. 
> > However, after a re-scanning , there is still folder A, and the folder 
> have 
> > media files which have 0bytes. 
> > is there anyone who have this kind of problem? if so, please give me 
> some 
> > advise. it would be much appreciated. 
> > 
> > Hyuck. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Android Developers" group. 
> > To post to this group, send email to [email protected] 
> > To unsubscribe from this group, send email to 
> > [email protected] 
> > For more options, visit this group at 
> > http://groups.google.com/group/android-developers?hl=en 
>
>
>
> -- 
> Mark Murphy (a Commons Guy) 
> http://commonsware.com | http://github.com/commonsguy 
> http://commonsware.com/blog | http://twitter.com/commonsguy 
>
> _The Busy Coder's Guide to Android Development_ Version 3.7 Available! 
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to