How to I find who sent a picture to me via Facebook Messenger? I found a picture saved to my gallery from the Facebook Messenger app. How can I find out who sent this picture to me?

When I go to the picture and click on details it tells me:

title: received_123456789012345
time: 13-7-15 8:43 
type: image/jpeg 
resolution: 450x744 
orientation: 0° 
size: 19.18kb 
path:/storage/emulated/0/DCIM/Facebook/received_123456789012345.jpg
It would be a privacy disaster if the meta information of that image contains the name or email ID of the sender. Anyhow, this answer assumes that the message (not the whole thread) from which you downloaded the image exists in your inbox. If you've deleted the message, ignore this answer.  

In the file name received_123456789012345, the numeric string after received_ is the identifier (ID henceforth) of that image on Facebook. 

If you happen to open that image from the message using a web browser in your mobile (if you're on desktop, switch user-agent to mobile), notice the string next to fbid= in the URL bar:


https://m.facebook.com/messages/attachment_preview/?mid=mid.145450XXXXXXXXXXXXXXXXXXXXXXXXXXX&threadid=id.20XXXXXXXXXXXX&fbid=ID


It would be the same ID you saw in the title of the file you earlier downloaded. 


  How can I find out who sent this picture to me?


The sender's name of that image is in the column sender of table messages in database threads_db2 located under /data/data/com.facebook.orca/databases/. 

Facebook Messenger app doesn't participate in backup and restore infrastructure of Android, so the only way to access that database is with root privilege.

Once you've root privilege, copy the aforesaid database to internal or external SD card. 

Get info using apps

On Android


Download an app that can open an SQLite database. (I prefer SQLite Editor.) 
Open the database in that app, open the table messages and if the app supports searching in all or particular fields then look into all or attachments the ID of that image.
In the resulting row, the text in the column sender has the sender's name next to "name":.

(Click image to enlarge)






On PC

If no Android  app works for you, copy the database into PC and use an application that supports exporting a table into a format understood by a browser or text editor. Once you have the application, use it to export the table messages and search ID in the exported output. 

I used Sqliteman. It supports exporting a table to HTML, CSV, XLS, among other formats. 

Command-line

If you're up to the task, you can try a command-line way. Copy the database into PC, download sqlite3 tool, setup adb in PC and do:


sqlite3 -line DB_PATH "SELECT sender,attachments FROM messages WHERE attachments LIKE '[{%'" | grep -B1 "ID" | grep "sender"  # DB_PATH is the path to threads_db2 and ID is content identifier


(MS Windows doesn't come with grep utility. You'll have to download it. Otherwise, remove everything after '[{%'" and sort and search the output on your own.)

Note: Some Android versions are shipped with sqlite3 tool. You can run that last command in your Android, if you intend to. 

Demo Output:


sender = {"email":"10000XXXXXXXXXX@facebook.com","user_key":"FACEBOOK:10000XXXXXXXXXX","name":"Lol Cat"}