2

我正在尝试从 google nexus 访问 rdf 文件.....(现在此代码能够从磁盘访问 rdf 文件)......因为 google nexus 没有 sdcard 插槽.....所以我是有问题来定义将从中检索 rdf 文件的路径....

   public class andro extends Activity implements View.OnClickListener{
    /** Called when the activity is first created. */

Graph graph;
Load ld;
Mappings map;
QueryProcess exec;
ResultFormat f;
RDFFormat f3;

Button runbtn;
Button clearbtn;
Button test;
Button triple;
EditText et1;
TextView tv1;

@Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.query);


   clearbtn = (Button) findViewById(R.id.clear) ;
   runbtn = (Button) findViewById(R.id.run);
   test = (Button) findViewById(R.id.test);
   triple = (Button) findViewById(R.id.rdf);

   tv1 = (TextView) findViewById(R.id.output); 
   et1 = (EditText) findViewById(R.id.input);


   clearbtn.setOnClickListener(new OnClickListener(){
       public void onClick(View v){
           et1.setText("");
           tv1.setText("");


       }
   });
      test.setOnClickListener(new OnClickListener(){
    //runbtn.setOnClickListener(new OnClickListener(){
      public void onClick(View v){

 /*     String op = et1.getText().toString();   
      tv1.setText(op);  
 */
   // graph = Graph.create();    
     graph = Graph.create(true);

      ld = Load.create(graph);
      ld.load("/user/roy/home/DownLoad/foaf.rdf");
     // ld.load("dataset.rdf");
     /* 
      try {
        ld.loadWE("dataset.rdf");
    } catch (LoadException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
     */ 
     // String query = null;
    //  Mappings map = null;


    //   String query1 = "select * where {?x ?p ?y}";

     exec = QueryProcess.create(graph); 
     query1 = et1.getText().toString();
      try {
          map = exec.query(query1);
            } catch (EngineException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // f = ResultFormat.create(map);
        // f3 = TripleFormat.create(map);
         String f2 = ld.toString();
         tv1.setText(ld);   
        //System.out.println(f2);           

         }  
      });

   }  

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

}   
 }

提前致谢....

4

1 回答 1

1

虽然 Nexus 没有可移动的 sd 卡,但它基本上仍然有一个内部的。因此,对于外部存储,您可以像平常一样对待它,如果您可以移除 SD 卡:

String SD_CARD = Environment.getExternalStorageDirectory() + "/my/path";
于 2012-05-14T21:06:19.167 回答