///
/// check read/write permissions
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
mExternalStorageAvailable = mExternalStorageWriteable = true;
Log.i(TAG,"read + write");
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
// We can only read the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
Log.i(TAG,"read");
} else {
// Something else is wrong. It may be one of many other states, but all we need
// to know is we can neither read nor write
mExternalStorageAvailable = mExternalStorageWriteable = false;
Log.i(TAG,"nothing");
}
///
/// write text file
File testFile = new File(Environment.getExternalStorageDirectory()+"/test.txt");
try{
testFile.createNewFile();
}catch(IOException e){
Log.e("IOException", "exception in createNewFile() method");
}
//we have to bind the new file with a FileOutputStream
FileOutputStream os = null;
try{
os = new FileOutputStream(testFile);
}catch(FileNotFoundException e){
Log.e("FileNotFoundException", "can't create FileOutputStream");
}
PrintWriter pw = new PrintWriter(os);
pw.println("test");
pw.close();
Log.i(TAG,"wrote in: " + Environment.getExternalStorageDirectory()+ "/test.txt");
jueves, junio 09, 2011
Write a text file in Android using the emulator in Eclipse
viernes, mayo 27, 2011
Install subclipse (subversion) in Eclipse in a few steps
To install Subclipse (subversion) repository plugin in Eclipse, do the following:
Note that you need internet connection :)
- 1. Open Eclipse
- 2. Help -> Install new software...
- 3. Click "Add.."
- 4. Add this repository (the name does not matter; the URL does):
http://subclipse.tigris.org/update_1.6.x
- 5. Type "subclipse" in the blank caption to search the plugin
- 6. Select it and install it
Note that you need internet connection :)
martes, marzo 15, 2011
Grooveshark: alternativa (también gratuita) a Spotify
¿Tienes problemas con Spotify?
¿No conoces las alternativas?
¿Quieres tener acceso a toda la música desde el propio navegador?
Grooveshark: http://listen.grooveshark.com
jueves, febrero 24, 2011
martes, diciembre 14, 2010
YouTube para el salón
Si eres de los que conecta el ordenador a la televisión y ve vídeos de YouTube desde el sofá de casa, seguro que te gustan estas versiones de YouTube.
La primera es una versión gigante, y se llama "XL":
La otra es una versión a pantalla completa, y se llama "Leanback":
a disfrutar!!!
La primera es una versión gigante, y se llama "XL":
http://www.youtube.com/xl
La otra es una versión a pantalla completa, y se llama "Leanback":
http://www.youtube.com/leanback
a disfrutar!!!
domingo, diciembre 12, 2010
LaTeX compiling error
If you are compiling a LaTeX document, and you get the following error:
! I can't find file `ptmr7t'Here you have the solution:
sudo apt-get install texlive-fonts-recommended
lunes, diciembre 06, 2010
Fix @ (at) character problem with Ubuntu in Macbook
If you can't write the @ character in Ubuntu, you should do this:
1. System > Preferences > Keyboard
2. Go to Keyboard Distribution label
3. Click Options
4. Look for something like "Key to access the third level" (sorry, my Ubuntu is Spanish ;-)
5. Select the key you are used to use when typing the @ symbol (I selected the "Alt" key)
That's all,
Enjoy!!
Some keywords for spanish readers: arreglar, problema, arroba, macbook, ubuntu
1. System > Preferences > Keyboard
2. Go to Keyboard Distribution label
3. Click Options
4. Look for something like "Key to access the third level" (sorry, my Ubuntu is Spanish ;-)
5. Select the key you are used to use when typing the @ symbol (I selected the "Alt" key)
That's all,
Enjoy!!
Some keywords for spanish readers: arreglar, problema, arroba, macbook, ubuntu
jueves, noviembre 18, 2010
Install Qt Ruby (qt4-qtruby) in Linux / Ubuntu
Hi!!
You only need to do this:
Maybe you need to install "qt4-dev-tools" if you do not have Qt4 libraries installed in your system.
Enjoy!!
PS: here I include a sample code to test if it works fine:
You only need to do this:
sudo apt-get install ruby libqt4-qtruby
Maybe you need to install "qt4-dev-tools" if you do not have Qt4 libraries installed in your system.
Enjoy!!
PS: here I include a sample code to test if it works fine:
require 'Qt4'
app = Qt::Application.new(ARGV)
window = Qt::Widget.new()
window.resize(200, 120)
quit = Qt::PushButton.new('Quit', window)
quit.font = Qt::Font.new('Times', 18, Qt::Font::Bold)
quit.setGeometry(10, 40, 180, 40)
Qt::Object.connect(quit, SIGNAL('clicked()'), app, SLOT('quit()'))
window.show()
app.exec()
miércoles, noviembre 10, 2010
Error while compiling Qt 4.7.1 in Debian Ubuntu (solved)
Did you get this error?:
You might need to modify the include and library search paths by editing QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11Just do this:
sudo apt-get install libx11-dev libfreetype6-dev libavahi-gobject-dev libSM-dev libXrender-dev libfontconfig-dev libXext-dev
miércoles, noviembre 03, 2010
Tutorial rápido de C# (C Sharp)
Parte 1: Conceptos básicos
///
/// TUTORIAL RÁPIDO DE C# (C Sharp)
/// (Parte 1)
///
/// * Vía: http://www.csharp-station.com/Tutorial.aspx
///
// **********************************
// * Tipos básicos de datos en C# (C Sharp)
Type Size (bits) Range
======== =========== ===========================================
sbyte 8 -128 to 127
byte 8 0 to 255
short 16 -32768 to 32767
ushort 16 0 to 65535
int 32 -2147483648 to 2147483647
uint 32 0 to 4294967295
long 64 -9223372036854775808 to 9223372036854775807
ulong 64 0 to 18446744073709551615
char 16 0 to 65535
Type Size (bits) Precision Range
======== =========== ==================== ===========================
float 32 7 digits 1.5 x 10-45 to 3.4 x 1038
double 64 15-16 digits 5.0 x 10-324 to 1.7 x 10308
decimal 128 28-29 decimal places 1.0 x 10-28 to 7.9 x 1028
// **********************************
// * Arrays de variables/objetos en C# (C Sharp)
string[] names = {"Cheryl", "Joe", "Matt", "Robert"};
// **********************************
// * Crear un programa básico en C# (C Sharp)
// Namespace Declaration
using System;
// Program start class
class WelcomeCSS
{
// Main begins program execution.
static void Main()
{
// Write to console
Console.WriteLine("Welcome to the Tutorial!");
}
}
//* o leyendo los parámetros que se pasan por consola
using System;
// Program start class
class NamedWelcome
{
// Main begins program execution.
static void Main(string[] args)
{
// Write to console
Console.WriteLine("Hello, {0}!", args[0]);
Console.WriteLine("Welcome to the Tutorial!");
}
}
// **********************************
// * Escribir/leer en la consola en C# (C Sharp)
Console.WriteLine("Hello console!!");
// Write to console/get input
Console.Write("What is your name?: ");
Console.Write("Hello, {0}! ", Console.ReadLine());
Console.WriteLine("Welcome to the C# Station Tutorial!");
// * ó
string name = Console.ReadLine();
// **********************************
// * Estructura de los métodos
bool createAddress(string name)
{
Address addr = new Address(name);
storeAddress(addr);
return true;
}
// **********************************
// * Crear clases en C# (C Sharp)
using System;
public class Echo
{
string myString;
public Echo(string aString)
{
myString = aString;
}
public void Tell()
{
Console.WriteLine(myString);
}
}
public class Hello
{
public static void Main()
{
Echo h = new Echo("Hello my 1st C# object !");
h.Tell();
}
}
// **********************************
// * Estructuras de control en C# (C Sharp)
// if, and else if, and else
// Multiple Case Decision
if (myInt < 0 || myInt == 0)
{
Console.WriteLine("Your number {0} is less than or equal to zero.", myInt);
}
else if (myInt > 0 && myInt <= 30)
{
Console.WriteLine("Your number {0} is in the range from 21 to 30.", myInt);
}
else
{
Console.WriteLine("Your number {0} is greater than 30.", myInt);
}
// switch with integer type
switch (myInt)
{
case 1:
Console.WriteLine("Your number is {0}.", myInt);
break;
case 2:
Console.WriteLine("Your number is {0}.", myInt);
break;
case 3:
Console.WriteLine("Your number is {0}.", myInt);
break;
default:
Console.WriteLine("Your number {0} is not between 1 and 3.", myInt);
break;
}
// while loop
while (myInt < 10)
{
Console.Write("{0} ", myInt);
myInt++;
}
// do-while loop
do
{
// Print A Menu
Console.WriteLine("Something\n");
} while (condition != false);
// for loop
for (int i=0; i < 20; i++)
{
if (i == 10)
break;
if (i % 2 == 0)
continue;
Console.Write("{0} ", i);
}
// foreach loop
string[] names = {"Cheryl", "Joe", "Matt", "Robert"};
foreach (string person in names)
{
Console.WriteLine("{0} ", person);
}
// **********************************
// * Namespaces en C# (C Sharp)
namespace ns1
{
namespace ns2
{
// Program start class
class NamespaceCSS
{
// Main begins program execution.
public static void Main()
{
// Write to console
Console.WriteLine("This is a Namespace.");
}
}
}
}
Suscribirse a:
Entradas (Atom)