Draeko Draeko - 1 year ago 135
Java Question

How to get Facebook Messenger conversation programmatically and store it to local database?

Pardon me for this newbie question, but i tried to search StackOverflow for the answer and found nothing but APIs etc.

Is there any chance in whatever way we can access the messages or conversation in Facebook Messenger programatically? The time, exact message, sender, audio, video, send and received photos, etc. and If possible, store it to lacal database for future use?

Thank you.

Answer Source

Problem #1:

I don't think FB messenger does store data (messages) on the phone. You can test this out.

Look at your current Messenger apps data and cache usage in your phone's setting. Example: my FB messenger only uses 34.11MB data on device and 56.19 cache. If you put your phone in Airplane/Flight mode and open Messenger, it shows a warning and if you open any chat, it will only load what is cached. Try to scroll up, it won't load. Now, close the app, turn airplane mode off, clear your data and cache and check again. You will be loading data is slightly slower because it pulls data from their servers.

Problem #2 (BIGGER PROBLEM):

Even if they did stored data on the phone (not counting media - pictures, video, etc.), it is all stored in app's internal directory. meaning: you can't access it (unless your phone is rooted). That would be the end of that.

Note: All media is stores in public storage and any app can access it. This is how Google Photos app is able to save every image I get and upload it to my google Photos. Photos/Videos will be saved under: /sdcard/Pictures/Messenger/


An idea (just an idea, not tested): You can create a NotificationListenerService which will allow you access to ALL incoming notifications on that device. Then, you filter out which of those notifications came from FB Messenger and then you can read it's content.

Problems I foresee:
1) If you want to put this in market, not a lot of people will trust it. After all, you have access to all their notifications.

2) If the user has disabled notification for that app or even just for that one chat within the app, you will not be able to record that info.

My suggestion: I'm not sure what or why you are trying to achieve but it just doesn't seem like a good idea. But you are always welcome to try it out.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download