Store String Key-value pair

Viewed 27076

I am developing an android app, the main work of app is there is a scanner and i have to scan again & again and store result in key value pair.

  [
   {
    "0" : "816444014066",
    "1" : "747083010945",
    "2" : "816444010969"
  }
 ]

and by API i have to send all the scan result by array. I am getting scan result by another activity by startActivityForResult.User will scan again and again and by onActivityResult user will get result.i have to store all the result in key value pair and finally there is a button by tap on button by POST request i have to send all the scan result by array like above code.

Can i use here HashMap or i have to use Shared Preferences for storing result.

// Call Back method  to get the Message form other Activity
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // check if the request code is same as what is passed  here it is 2
        if (requestCode == 2 && data!=null) {
            String message = data.getStringExtra(SCAN_RESULT);
            // textView1.setText(message);
            if(message!= null){
                Log.e("SCAN_RESULT", "" + message);

                //Adding code will be here


              }
        }
    }
9 Answers
Related