Access to external applications

2011-01-11  来源:本站原创  分类:Mobile  人气:105 

Using the context of the file output stream which has four modes:
* File read and write modes of operation:
* Context.MODE_PRIVATE = 0: only the application to operate the current file if the file already exists to create new original content covering
* Context.MODE_APPEND = 32768: new content added to this model after the original content of this document is proprietary applications can only be accessed by creating a file
* Context.MODE_WORLD_READABLE = 1: allow other applications to read files created in this application
* Context.MODE_WORLD_WRITEABLE = 2: to allow other applications to write files created in this application, it will overwrite the original data.
* /

When an application's operating mode is Context.MODE_WORLD_READABLE this mode can be used to access the external application

SharedPreferences for data storage with this chapter if the application is Context.MODE_WORLD_READABLE SharedPreferences mode of operation so you can use this to access external applications

Xml code to access external applications

package it.cast;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.util.Log;

public class OtherXml extends Activity {
private static final String tag = "OtherXml";
@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
/ / Build the context of other applications to access information
try {
Context context = this.createPackageContext ("itcast.date", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences pre = context.getSharedPreferences ("itcast", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
int age = pre.getInt ("age", 1);
String name = pre.getString ("name", "");
Log.i (tag, "age:" + age + ", name:" + name);
} Catch (NameNotFoundException e) {

Log.i (tag, e.toString ());
}
}
}

Exception handling:

01-11 07:28:27.463: ERROR / AndroidRuntime (216): Caused by: java.lang.SecurityException: Requesting code fro

This is a security exception exception

Can modify the context of the access mode Context.CONTEXT_INCLUDE_CODE as ------------ Context. CONTEXT_IGNORE_SECURITY will be solved

相关文章
  • Access to external applications 2011-01-11

    Using the context of the file output stream which has four modes: * File read and write modes of operation: * Context.MODE_PRIVATE = 0: only the application to operate the current file if the file already exists to create new original content coverin

  • linux shell awk access to external variables (variable-value) Introduction 2011-08-05

    Mentioned here awk, shell's friends believe that writing will come into contact. AWK is a programming language for working with text tools. AWK provides an extremely powerful: Can match the regular expression Style into Flow Control Mathematical Oper

  • The unit can access the IIS site, but can not access the external machine 2010-12-28

    Problems may arise in the following reasons: 1 In the Security tab of the site, there is no check using the anonymous user. 2 sites where the firewall does not allow external access to the machine. The solution can select an exception, release http80

  • How to access the external network within a network server 2011-08-29

    This article is from Baidu Q http://zhidao.baidu.com/question/261441575.html How to access external network within a network? How to configure the router? Home owners want remote access server, the company server IP192.168.1.8 DNS: 192.168.1.8 Best a

  • Set mysql to allow access to external networks 2010-03-18

    mysql's root account, I am usually in connection with the localhost or 127.0.0.1, the company's test server mysql is localhost so I would like to access can not access the test moratorium. Solution as follows: 1, modify the table, log mysql database,

  • Access to external network IP address of the machine (External IP Address) 2010-12-15

    import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Gets the native outside the n

  • Flex access to external parameters (URL parameters) 2010-04-26

    On this issue has been confused for a long time, but also to find a way to try a lot, but mostly can not be achieved Can be achieved as follows First find Flex3 generated preview with the page. Usually $ (defaultMXML). Html. Direct paste code: <scrip

  • java access to external network ip 2010-07-02

    package Test; import java.awt.Font; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.SocketTimeoutException; import

  • CentOS can not access the external network problems 2011-09-23

    1, the network card configuration information is checked with ifconfig 2, the gateway to set parameters through the route inspection 3, dns configuration information see the cat / etc / resolv.conf

  • applications to access non-ssl ssl content boxes pop-up security issues 2010-10-23

    We all know that if our application is based on the ssl, then you need to access our application via https, this time if you need to send a request for external http requests, the browser will pop up a security prompt window as shown: View the site a

  • java using a proxy server to access the network 2010-03-29

    This technique will show you on how to write access to the Internet through a proxy Web server Java applications. In the Java applications by adding an extra agent support just write a few lines of code, and does not rely on any security "loopholes.&

  • Ning shield Password Applications: OA integration in a big oil field licenses dKey dynamic password authentication 2010-03-23

    I. Background A well-known domestic oil should the requirements of informationization, developed a few years ago based on B / S Mode OA system meets the requirements of office, the staff daily office through this system, and OA servers deployed in th

  • Test Web applications using techniques JAWS 2010-10-31

    Introduction to screen readers Screen reader (Screen Reader) is to try and identify the understanding of the information currently displayed on the screen of a software application, the screen reader interface to identify the current through the Acce

  • Introduction to Android applications and application management 2010-11-01

    This pre-Internet sources: I. Overview 2007, Google introduced a Java-based Android platform, attracted the same attention to IT industry, the same year, the company began developing Borqs the OPhone based on its platform. 2008, the first Android pho

  • Dynamic Web applications using WebKing test 2010-11-10

    Introduction: This article from the static analysis WebKing page paper discusses the use of WebKing to support Ajax, methods for testing dynamic pages, and this unit and functional testing from the point of view on the use of WebKing test Accessibili

  • Building Semantic Web Applications - build Semantic Web applications 2010-12-09

    wiki Address: http://protegewiki.stanford.edu/wiki/BuildingSemanticWebApplications Main article: ProtegeOWL_API_Programmers_Guide Building Semantic Web Applications - build Semantic Web applications Protege-OWL API can build a standalone application.

  • Building Semantic Web Applications - build a Semantic Web application 2010-12-09

    wiki Address: http://protegewiki.stanford.edu/wiki/BuildingSemanticWebApplications Main article: ProtegeOWL_API_Programmers_Guide Building Semantic Web Applications - build a Semantic Web application You can use the Protege-OWL API to build a standal

  • Oracle database instance and Access transconductance 2011-06-08

    (1) the practical relevance of the Access data into Oracle database applications step is to first open the Access database, choose what you need to import the table, the table name and column name in all capital letters rewritten (to Oracle database,

  • ArcGIS Engine in Data Access 2010-03-19

    GIS data is the foundation of any access to data is a complex spatial analysis and spatial visualization premise. ArcGIS supports rich data formats, different data formats on the level of support is also very different. This paper introduce the follo

  • java and non-static inner classes static inner classes, and their definition of external 2010-04-20

    Interface: a statement of the attributes in the interface automatically become public static final statement of the methods in the interface automatically become a public declaration in the interface of the class automatically become a public static