i created folders on external storage. in device these folders are created properly and i can see and use them. now i want to see these created folders on my PC if i connect it to USB.but i was not able to see any of the created folders. after that i used MediaScannerConnection class for media scan for given folder path . after that i am able to see the created folder but the innermost folder on a particular path is not visible properly. for example suppose i created 3 folder(pragmatically) and for example i want to create folder abc/def/h so on external storage of my phone than path in file explorer of eclipse is mnt/shell/emulated/0/abc/def/h and in our phone we can see it in file Manager internal storage/abc/def/h. but the problem is after using MEdia Scanner i cab see folder in PC but the innermost folder "h" which i created is not resemble like a folder , it becomes a file of 4kb not a folder. so like this if create lots of folder the inner most folder is not a type of file folder, but a type of file only.. although if i dont use mediascanner and do power off and power on my phone than it works properly means after power on / off i can see all the created folder properly . but i want to see the created folders just after creation.my code is as follows
public void ReadFileAndMakeFolders(Context context){
File file3;
File file2;
String[] splitedString;
try {
//Attaching BufferedReader to the FileInputStream by the help of InputStreamReader
FileInputStream fis = context.openFileInput("databaseee.txt");
InputStreamReader isr = new InputStreamReader(fis,"UTF-8");
BufferedReader bufferedReader = new BufferedReader(isr);
int i=0;
String inputString;
//Reading data line by line and storing it into the stringbuffer
while ((inputString = bufferedReader.readLine()) != null) {
i++;
splitedString = inputString.trim().split("\\s+");
Toast.makeText(this, splitedString.length+""+ splitedString[1], Toast.LENGTH_SHORT).show();
file2 = new File(splitedString[1]);
file3 = file2.getParentFile();
Log.i("mistake",file3.toString());
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
Toast.makeText(this, state, Toast.LENGTH_SHORT).show();
}
File path = Environment.getExternalStorageDirectory();
File file = new File(path, file3.toString());
if (file.mkdirs()) {
Toast.makeText(this, "created" , Toast.LENGTH_SHORT).show();
}
MediaScannerConnection.scanFile(this, new String[] { file.toString() }, null,
new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("ExternalStorage", "Scanned " + path + ":");
Log.i("ExternalStorage", "-> uri=" + uri);
}
});
}
fis.close();
bufferedReader.close();
isr.close();
} catch (IOException e) {
e.printStackTrace();
}
//Displaying data on the toast
}