-1

I am developing an application related to home automation in android.

Suppose the name of my application is X and is installed on two different android Devices(user1 & user2)

I want to share the data(key value pair) of app X from user1 to the same app in user2

I dont want to use internet.

can we do it with sharedpreferences or bluetooth??

but data should transfer from app to app.

How to achieve this???

Pranita
  • 803
  • 7
  • 16
  • Yes can use wifi peer to peer connection to communicate two devices in limited area. – Mayank Pandya Nov 03 '17 at 05:55
  • can you tell me how to do this ?? or any link for reference? any code sample – Pranita Nov 03 '17 at 05:58
  • https://stackoverflow.com/a/22899728/3364266 try this – Samir Bhatt Nov 03 '17 at 06:00
  • https://stackoverflow.com/questions/39589868/how-to-broadcast-message-from-group-owner-to-all-or-particular-clients-andro check this link... you can connect multiple devices in same network using this and can also send and receive data from any connected device. – Mayank Pandya Nov 03 '17 at 06:04
  • @samir..thanks for the link..I can send the data with this link..but i want to receive data in same app on other device.how to do that? – Pranita Nov 03 '17 at 06:05

1 Answers1

0

You can do this by sending a JSON object, through Bluetooth. After recieving the value from the other end, you can parse the JSON.

  • I cant use JSON that's the main problem. – Pranita Nov 03 '17 at 05:58
  • JSONObject student1 = new JSONObject(); try { student1.put("id", "3"); student1.put("name", "NAME OF STUDENT"); student1.put("year", "3rd"); student1.put("curriculum", "Arts"); student1.put("birthday", "5/5/1993"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } – Souvik Brahma Nov 03 '17 at 06:01
  • Now you can send the json student1 to your other device, and parese the content – Souvik Brahma Nov 03 '17 at 06:02