Wednesday 14 May 2014

Create text file in SDCard in Android Studio using Java

Code :
try
{
            FileWriter _fs=new FileWriter("/sdcard/Employee_Info.txt");
            BufferedWriter out=new BufferedWriter(_fs);
            out.write(_data);
            out.close();
            Toast.makeText(this,"Information Saved",Toast.LENGTH_SHORT).show();
 }
 catch (Exception e)
 {
            
 }

where _data=data you want to save to the file

Before Executing this code ,make these settings
1.
Go to Application Explorer :
Application -> app->src->res->AndroidManifest.xml

<manifest>
<application>
</application>
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

</manifest>

uses-permission must be outside the <application></application>

2.
Go to Application Explorer :
Application -> app->src->build.gradle

Add this piece of code inside android {}:
android
{
lintOptions{
        abortOnError false
    }
}

what is lint ?
The Android lint tool is a static code analysis tool that checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization.

3.
Provide the size for the SD card in AVD(Android Virtual Device) Emulater


eNjOy tHe cOdInG 

Get CSV Values in SQL

Query: DECLARE @CSVValue NVARCHAR(50)='100,101,102'                   DECLARE @eachValue NUMERIC(9,0)   while len(@CSVValue) &...