When I had the Target API 29, the app was showing WhatsApp statuses, but when I increase the target api to 32, it is not showing the statuses.
public File getWhatsupFolder() {
if (new File(Environment.getExternalStorageDirectory().toString() + File.separator + "Android/media/com.whatsapp/WhatsApp" + File.separator + "Media" + File.separator + ".Statuses").isDirectory()) {
return new File(Environment.getExternalStorageDirectory() + File.separator + "Android/media/com.whatsapp/WhatsApp" + File.separator + "Media" + File.separator + ".Statuses");
} else {
return new File(Environment.getExternalStorageDirectory() + File.separator + "WhatsApp" + File.separator + "Media" + File.separator + ".Statuses");
}
}
Here is the code of my getting status that was working fine in target api 29.
If anyone knows what is the issue. Please let me know. Thanks in advance.
Related
I am using grails 2.1.1. I want to change a file name on a event. That's why I have attempt some. I just want to rename the file. But my process is not working. Can anyone please help me on this please?!!! Here is my attempt below in controller >>>
String previousFileName = inceptionInstance.fileName
StringBuffer newFileName = new StringBuffer(previousFileName);
int start = 0;
int end = previousFileName.indexOf("_");
newFileName.replace(start, end, params.firmName);
File f = new File(grailsApplication.config.files.location.toString() + File.separatorChar + previousFileName);
f.renameTo( new File( grailsApplication.config.files.location.toString() + File.separatorChar + newFileName) )
I have solved the issue. Just take a look at this ...
new File(grailsApplication.config.files.location.toString() + File.separatorChar + previousFileName).renameTo(new File(grailsApplication.config.files.location.toString() + File.separatorChar + newFileName))
I am trying to convert a wav file into mp3 format using the below code. A mp3 file is created but it is blank file without any content. Any ideas what could be causing this.
Format[] FORMATS = new Format[] { new AudioFormat(
AudioFormat.LINEAR) };
String srcFilePath = "C:" + File.separator + "Users"
+ File.separator + "vkiran" + File.separator + "Desktop"
+ File.separator + "test" + File.separator + "4a714ea2.wav";
String mp3FilePath = "C:" + File.separator + "Users"
+ File.separator + "vkiran" + File.separator + "Desktop"
+ File.separator + "test" + File.separator + "4a714ea2.mp3";
File srcFile = new File(srcFilePath);
File destFile = new File(mp3FilePath);
MediaLocator source = new MediaLocator(srcFile.toURL());
DataSource d = Manager.createDataSource(source);
ContentDescriptor cd = new ContentDescriptor(
FileTypeDescriptor.MPEG_AUDIO);
Processor p = Manager.createRealizedProcessor(new ProcessorModel(d,
FORMATS, cd));
p.configure();
System.out.println((p.getDuration()).getSeconds());
MediaLocator destination = new MediaLocator(destFile.toURL());
DataSource ds = p.getDataOutput();
DataSink sink = Manager.createDataSink(p.getDataOutput(),
destination);
sink.open();
sink.start();
sink.stop();
sink.close();
p.stop();
p.close();
Here i'm able to change the name of image but for the new image i'm not getting the same image as first one.
Here my initial image is ABC.png and new image is XYZ.png i'm able to change the image name from ABC.png to XYZ.png but i need XYZ.png as similar to ABC.png just i need to change name of image.
Here is my code
File prevfile = new File(ImagesPath + "/" + oldvalue + ".png");
File nextfile = new File(ImagesPath + "/" + newValue + ".png");
prevfile.renameTo(nextfile);
File prevfile = new File(ImagesPath + "/" + oldvalue + ".png");
File nextfile = new File(ImagesPath + "/" + newValue + ".png");
//prevfile.renameTo(nextfile);
Rather than renameTo function better use
FileUtils.copyFile(prevfile , nextfile );
prevfile .delete();
Rename Image with new name and delete previous name.
I am trying to create a file, but file path is constructed through String Concats that uses some internal variables and labels, I am getting following error :
Exception in thread "main" java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at CopyEJ.CopyEJ.main(CopyEJ.java:133)
Is there a standard approach to built such files ?
String s_path = text_dir + "\\" + time_stmp + "_" + "Session" + "_" + file_name;
File ssw = new File(s_path);
ssw.createNewFile(); //Errors Out here
You need to create the folder (directory) first:
String s_path = text_dir + "/" + time_stmp + "_" + "Session" + "_" + file_name;
File ssw = new File(s_path);
ssw.getParentFile().mkdirs();
ssw.createNewFile();
This will help you:
String path = "D://abc" + filename+ ".txt";
System.out.println("Path--- " + path);
File file = new File(path);
file.createNewFile()
If You are using Java 1.7 you can rewrite it as follows:
Path s_path = Paths.get(text_dir, time_stmp + "_" + "Session" + "_" + file_name);
Files.createDirectories(s_path.getParent());
File ssw = s_path.toFile();
ssw.createNewFile();
Paths.get() will use default system path separator.
I have a program which reads a file every time and now I want to read the event log file of windows ,how can I get the location and read its contents.
The logs are stored in the %SystemRoot%\System32\Config directory with a .evt extension. Within the Computer Manager you can also export them to a .txt or .csv file.
Windows Vista/7/Server2008 location, here it is: %SystemRoot%\system32\winevt\logs
My Code is:
String fileSeperator = File.separator;
String filePath = "C:" + fileSeperator + "WINDOWS" + fileSeperator + "system32" + fileSeperator + "winevent" + fileSeperator + "logs";
System.out.println("FilePath :" + filePath);
File f = new File(filePath);
System.out.println("Is Directory :" + f.isDirectory());
The Output:
FilePath : C:\WINDOWS\system32\winevent\logs
Is Directory :false
Why does it return it is not a directory?
Because the file doesn't exist. You said yourself that the location was %SystemRoot%\system32\winevt\logs. Yet you use C:\WINDOWS\system32\winevent\logs.
winevt != winevent.