-1

How can I have a small file, containing some data, which will be readable by more than one app even if only the reader is running? In fact my problem is: many small apps on a tablet, apps communicating with a web site. Each tablet is used by a specific group. At app installation, the owner of the tablette must indicate his group, but I dont want him to indicate for each app. So I want to have a small file, on the tablet, that each app will use to tell the Web service "I'm app from tablet from group X".

The Android doc talk about a communication system between apps, but seem to need apps are both running. Is there a way to indicate, (eg in "manifest") that one file is shared between app?

Thanks a lot for the answer Best regards to you all Peter

Peter
  • 1,247
  • 19
  • 33
  • Use a content provider and a content resolver. – 323go Aug 27 '14 at 13:30
  • 1
    Content provider and resolver seems to give me the answer. Thanks 323go, iIll take a look at that and make some test. – Peter Aug 27 '14 at 14:33
  • Great -- it has worked well for me. There are some samples out there (look for CommonsWare), but it's not too difficult to write something with a MatrixCursor. – 323go Aug 27 '14 at 16:45

1 Answers1

-1

Why not just dump a file onto the sdcard?

https://stackoverflow.com/a/8152217/1117029

public void generateNoteOnSD(String sFileName, String sBody){
    try
    {
        File root = new File(Environment.getExternalStorageDirectory(), "Notes");
        if (!root.exists()) {
            root.mkdirs();
        }
        File gpxfile = new File(root, sFileName);
        FileWriter writer = new FileWriter(gpxfile);
        writer.append(sBody);
        writer.flush();
        writer.close();
        Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
    }
    catch(IOException e)
    {
         e.printStackTrace();
         importError = e.getMessage();
         iError();
    }
   } 

And read that text file when looking for the "group"

Community
  • 1
  • 1
r2DoesInc
  • 3,759
  • 3
  • 29
  • 60