Premise: I am using WhatsApp on Android.
Why I am asking this
I am trying to create a script that, when configured with proper arguments, would restore accidentally deleted pictures in a WhatsApp chat, if you have a copy of those files somewhere else (with potentially different file names) and you pass them to the script.
What happens when you delete an image
Normally, if you accidentally delete the image files, WhatsApp still shows you a thumbnail, but if you click on it the following pop-up appears.
Therefore, I guess it looks for a filename in the storage and it tries to load that file.
I verified this
I tested this by manually replacing an image in the "WhatsApp Images" folder with another image, and the new image shows up in the corresponding chat as expected, so this is right.
But when I did that test, I knew the file name because I manually watched the file previews using a file manager and I identified the right file, so that was easy.
So the problem is
What about deleted files? how can I try to guess the corresponding file names in order to place the file copy back where it is supposed to be?
What I already know
First of all, I know the file names have this format:
IMG-yyyymmdd-WAxxxx.jpg
Where yyyymmmmdd is a date and xxxx is a sort of sequence number.
I also know that the mapping from thumbnails to actual files is stored in the msgstore.db database file, but it can only be accessed if you have root privileges. Do you think is there any other way to predict what the file name can be without accessing that DB?
Related
I have a gallery which is maintained through app and didn't want to give images a jpg extension since I didn't want images to display in phone gallery so users cannot accidentally delete them. Filenames are something like "gall.22", "gall.381", etc. In fact, there are jpeg files.
When I share one or multiple images, they are shared with their filename which is not ending with .jpg and therefore cannot be opened regularly if shared to email, Viber, etc.
Is there a way to share files with a custom name, not the original one (to add just .jpg at the end of filename) and to avoid copying file to another file with wanted name prior sharing?
I didn't want images to display in phone gallery
I think you can try another way instead of rename extension, you can create the folder to store images and create file .nomedia inside this folder. MediaScaner will ignore this folder when scan and you can share image in normal way.
to avoid copying file to another file with wanted name prior sharing
When you share a file by Uri to another app can handle directly by Uri or copy, it depends on another app handle
Well, I tried to search in google and SO, but didn't find much mainly because I am not sure what should be my search word. So, if anybody thinks this question is too generic and should be searched first, please help me providing some useful link.
What I want is, to have two buttons in my App which should download sample.csv and sample.php (I want to attach this file inside my App) file and save it to user directory, preferably in "download" folder or somewhere user can access easily.
I found this page by searching but here they demonstrates saving File on Internal Storage in App's folder only. Now I am confused whether this App's folder is accessible by browsing or not (I can't find my app's folder in my Samsung Note 2).
Another question pops up in my mind is, whether I have to read those sample files and create new file to save, or I can simply put a link and download the sample files I provided (more like HTML link)? Or may be I can just upload those sample files in my web server as zipped and give a link to dload?
Apology for my long email, but I am confused where to start.
Thanks,
You can not access your app's internal directory. However, what you can do is to use InputOutputStream to copy your file from the internal directory to your desired folder, and then delete the file from the app's directory. Try searching for copying files and you'll find multiple links.
In my application I am using a timestamp as my filename when I save it to a folder on my device.I know want to access one of these files from my application but I'm not sure how to open a file that you don't know the name of. They are all of the same file type so my question is how can this be done?
You probably want to save to a particular directory that only contains your timestamped files and nothing else. You can use the File.listFiles API to get an array of Files in your directory, you can then check each of the filenames to find the appropriate one (e.g. most recent timestamp).
You have to provide the name of file.Otherwise it would be like saying to JVM "do this?" without the idea of what to do?
i am making dictionary and i have so much data to load. I want that i create a project which first load the dictionary words in database and the after i use this .db file in my 2nd project which is dictionary project.
But i don't know how to get the .db file and copy it and paste it into my assets folder.
Well, yopu cant simply copy any files from one private storage, to another. I suppose you can archive this using different ways, for example:
1) Copy your .db file to SD card by first app, and copy it back to private storage by the second app.
2) You can use ContentProvider to share private data between 2 different applications without moving it on SD card.
You can'not get direct access to assest or any other data folder of different application. Good luck!
You can get resources from other package with PackageManager.getResourcesForApplication() method. Also you can share user id between your apps and sign them with share sertificate. In this case you can even share code base. +#Evos' suggestions.
I think share user id is your choise.
You can find examples and more info in this post and here.
Open Your previous project them open DDMS tab ,then go on path
data--->data---->your project---->databases--->.db file
now select that file and click on top right corner of screen here is a buuton to pull file from device to PC so click on that now a file dialog will appear select location to save file , now ok....this action will save your .db file on your selected location
now you can copy this file and put this file in your new projects assets folder and then use it.
I have an android application I am developing in Java.
I need it to load a text file so it can read what is in the text file and get values from it.
However, everything I have read so far has been directing me to use resources and package it up with the application.
However this means if I want to change the text file, I have to reinstall the application, which is not what I want.
I need to end up with the .apk file and the .txt file in the same folder on my android phone so I can change the .txt file and the app reads in the text file in its directory.
Can anyone help?
No, you do not want to end up with the .apk and the .txt file in the same folder.
You want to end up with the .txt in some place that's always the same and that you know about.
You can deploy the initial .txt via the ressources (aka: package it and copy it to the sd for example) and later download a new version (or copy something to the device via usb).
Then inside your app check if the file exists and open it with standard Java. There's plenty of source around for that.