android中项目中,需在 assets中,新建一个txt, 内容为json格式的username  pwd ,现需在android中的一个MaActivity.java中取username  pwd大家可直接贴代码,也可发我邮件[email protected]  thanks

解决方案 »

  1.   

    为什么不要用sharedPreference存储,小型的数据,这种方便啊
      

  2.   

    简单贴段代码:     InputStream is = getAssets().open("yourFileName");
         byte[] buffer = new byte[1024];
         ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
         int len = 0;
         while(-1 != (len = is.read(buffer))) {
         bos.write(buffer, 0, len);
         }
         JSONObject jsonObj = new JSONObject(new String(bos.toByteArray()));
         is.close();
         bos.close();
         String userName = jsonObj.getString("username");
         String pwd = jsonObj.getString("pwd");
      

  3.   

    还有更详细的吗,还可以发我邮件
    [email protected]