This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

reading Shared_prefs file of another application using content provider

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
So Im trying to solve a problem and I was previously posting on this trying to code a certain solution but I think I went up the wrong path and Android wouldn't let me access the file.

In my Android application, I'm trying to read the value stored in the shared_prefs folder of another application. That application exports a content provider.

Anyone any idea what way to code this.

Thanks,
Paul
 
Pol Denais
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so far I can read the value of the shared file by using the content uri: content://com.application1/shared_prefs/application1_conf.xml. Manually this pulls back the details of the XML file. Now I need some help below on my code below to read the file and pick out one value only. I don't want all the values in the Xml, just one. I then need to return this to the calling function.

appreciate any help


 
Rancher
Posts: 507
15
Notepad Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post what the contents of the file after reading it (from the variable buffer).
 
Pol Denais
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prasad,
Thats just at the stage where I am at now, wondering how to pick one value from the XML file. so this is where I need to improve:

BufferedReader reader1 = new BufferedReader(new InputStreamReader(content));
       String line1;
       StringBuffer buffer = new StringBuffer();
       try {
           while ((line1 = reader1.readLine()) != null) {
               //mTextResults.append(line1);
               buffer.append(line1);
           }
 
Crusading Chameleon likes the size of this ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!