小编and*_*oid的帖子

如何从服务器下载XML文件并将其保存在SD卡中?

在我的应用程序中,我试图从服务器下载XML文件并将其存储在SD卡中.为此我使用以下代码..

        try {
               File root = android.os.Environment.getExternalStorageDirectory();               

               File dir = new File (root.getAbsolutePath() + "/project");
               if(dir.exists()==false) {
                    dir.mkdirs();
               }

               URL url = new URL("url"); //you can write here any link
               File file = new File(dir, name);

               long startTime = System.currentTimeMillis();
               Log.d("DownloadManager", "download begining");
               Log.d("DownloadManager", "download url:" + url);
               Log.d("DownloadManager", "downloaded file name:" + name);

               /* Open a connection to that URL. */
               URLConnection ucon = url.openConnection();

               /*
                * Define InputStreams to read from the URLConnection.
                */
               InputStream is = ucon.getInputStream(); …
Run Code Online (Sandbox Code Playgroud)

android

5
推荐指数
2
解决办法
3万
查看次数

将sd卡中的xml文件设置为android中的布局

在我的应用程序中,我想从服务器获取布局文件,并将该文件设置为活动的内容视图.我想知道它是否可行.为此,我想到的是我将从服务器下载文件并将其存储在SD卡中,将从那里访问它.但是可以将文件设置为内​​容视图..请帮助我..

xml android android-layout

5
推荐指数
1
解决办法
973
查看次数

android中的共享首选项

我是android开发的新手.

我有一个活动,我正在使用用户名和密码.我将这些值传递给Web服务,该服务返回一个键作为响应.我在我的活动中有一个切换按钮.现在,如果用户检查切换按钮,这意味着他希望保持登录状态,并且下次登录时应将用户重定向到下一个活动.

如果选中了切换按钮,我将用户名,密码和密钥存储在共享首选项中.但我下次没有得到如何检索这些细节(即用户下次登录时)

android

2
推荐指数
1
解决办法
5566
查看次数

java.lang.outofmemoryerror位图大小超过位图上的vm预算

在我的应用程序中,我正在显示来自厨房的图像和选择的图像我想将该图像上传到Web服务器.为了将图像上传到服务器我正在使用以下代码但是我在bitmapImage = BitmapFactory.decodeFile(路径)时收到错误 ,选择);

private void uploadImage(String selectedImagePath) {
        String str = null;
        byte[] data = null;
        String  Responce= null;
        Bitmap bitmap2 = null;
        try {
            File file=new File(selectedImagePath);
            //FileInputStream fileInputStream = new FileInputStream(new File(imagePath2) );
            FileInputStream fileInputStream=new FileInputStream(selectedImagePath);
            Log.i("Image path 2",""+selectedImagePath+"\n"+fileInputStream);
            name=file.getName();
            name=name.replace(".jpg","");
            name=name.concat(sDate).concat(".jpg");
            Log.e("debug",""+name);

            //else
            //{
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inTempStorage = new byte[16*1024];

            //bitmapImage = BitmapFactory.decodeFile(path,opt);

            bitmap2=BitmapFactory.decodeFileDescriptor(fd, outPadding, opts)
            Log.i("Bitmap",""+bitmap.toString());
            BitmapFactory.decodeStream(fileInputStream);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            bitmap2.compress(Bitmap.CompressFormat.PNG, 100, baos);
            data = baos.toByteArray();
            str=Base64.encodeBytes(data);
            //} …
Run Code Online (Sandbox Code Playgroud)

android

2
推荐指数
1
解决办法
3805
查看次数

在android中的sqlite数据库中设置标志

在我的应用程序中,我想为收藏夹报价设置标志。单击按钮时,我想为该特定行设置该标志。在我的数据库中,对于报价,我采用了 TEXT 数据格式和 boo 精益 BOOL。我设法检索了文本值来自数据库,但我无法在数据库中设置布尔值。由于我是这个主题的新手,因此非常感谢您的帮助。下面是我的代码

public class DatabaseHelper extends SQLiteOpenHelper{
    //The Android's default system path of your application database.
    private static String DB_PATH = "/data/data/com.t4t.smspopup/databases/";
    private static String DB_NAME = "smspopupplus.sqlite";
    private static SQLiteDatabase myDataBase; 
    private final Context myContext;
    public static String Column_Favorite="0"; 

    public DatabaseHelper(Context context) {
        super(context, DB_NAME, null, 1);
        this.myContext = context;
    }

    public void createDataBase() throws IOException
    {
        boolean dbExist = checkDataBase();      
        SQLiteDatabase db_Read = null;
        if(dbExist)
        {

        }
        else
        {
            db_Read=this.getReadableDatabase();
            db_Read.close();
            Log.i("debug++++", "databse created"); …
Run Code Online (Sandbox Code Playgroud)

sqlite android

1
推荐指数
1
解决办法
5858
查看次数

标签 统计

android ×5

android-layout ×1

sqlite ×1

xml ×1